PHP Fatal error: Class 'Application\Sonata\MediaBundle\ApplicationSonataMediaBundle' not found in /var/www/znata.com/app/AppKernel.php on line 47

skonsoft picture skonsoft · Sep 5, 2012 · Viewed 8.3k times · Source

i followed this doc to install SonataMediaBundle but i got this error:

PHP Fatal error:  Class 'Application\Sonata\MediaBundle\ApplicationSonataMediaBundle' not found in /var/www/znata.com/app/AppKernel.php on line 47

After using the sonata command t generate the app:

php app/console sonata:easy-extends:generate SonataMediaBundle

new directory was generated under:

apps/Application/Sonata/MediaBundle

everything was done but when i registred the generated application in my AppKernel.php i got that error.

public function registerbundles()
{
    return array(
        ...
        new Application\Sonata\MediaBundle\ApplicationSonataMediaBundle(),
        ...
    );
}

Have you any idea how to fix this issue ?

Answer

Vyacheslav Enis picture Vyacheslav Enis · Sep 7, 2012

By default project root directory is not in the autoload path, only "src" dir. You can use

php app/console sonata:easy-extends:generate --dest=src SonataMediaBundle

to generate bundle in the src or simple copy it to the src.