I am trying to implement cache to a symfony app. I am using the FOSHttpCacheBundle, it works pretty fine I have don't problem with that. But when I was doing my test I got this error on a page :
Compile Error: Cannot redeclare class Symfony\Component\EventDispatcher\Event
Problem is I don't know how can I find the bug... I got it only in this page. The only thing I know is can fix this bug by commenting the line
$kernel = new AppCache($kernel);
which lead to
require_once __DIR__.'/AppKernel.php';
use FOS\HttpCache\SymfonyCache\UserContextSubscriber;
use FOS\HttpCache\SymfonyCache\PurgeSubscriber;
use FOS\HttpCacheBundle\SymfonyCache\EventDispatchingHttpCache;
class AppCache extends EventDispatchingHttpCache
{
public function getDefaultSubscribers()
{
$subscribers[] = new PurgeSubscriber(array('purge_client_ips' => 'localhost'));
return $subscribers;
}
}
So have an idea what do I need to check ?
It's a difficult to say "why" without debugging but you can try to check if class already registered
if(!class_exists('Symfony\Component\EventDispatcher\Event'){
use FOS\HttpCacheBundle\SymfonyCache\EventDispatchingHttpCache;
}