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

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


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.


After debug this problem, i found that the namspace Application is not registred.

In SF2.0, the documentation said that we should register this namespace like:

<?php$loader->registerNamespaces(array(    ...    'Application'   => __DIR__,    'Imagine'       => __DIR__.'/../vendor/imagine/lib',    'Gaufrette'     => __DIR__.'/../vendor/gaufrette/src',    'Buzz'          => __DIR__.'/../vendor/buzz/lib',    ...));

but in SF2.1 they did talked about this.

So i registred the namespace Application in autoload.php and it works fine.

so, the autoload.php look like this:

<?php// file: app/autoload.phpuse Doctrine\Common\Annotations\AnnotationRegistry;$loader = require __DIR__.'/../vendor/autoload.php';//custom for Application$loader->add("Application", __DIR__);// intlif (!function_exists('intl_get_error_code')) {    require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';    $loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');}AnnotationRegistry::registerLoader(array($loader, 'loadClass'));return $loader;

With this new config everything is fine.But in SF2.0, they talked also about "Imagine", "Guffrette" and "Buzz" namespaces. So perhapes, when using them, we should register them also like Application namespace.

I hope that this helps you.


Using composer I did this in composer.json: "autoload": { "psr-0": { "": "src/", "Application": "app/" } },

I added the mapping "Application": "app/".And then run composer update

This generated extra autoloading needed.