Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class Not found in AppKernel.php

I'm trying to deploy my Symfony2 project. When I run the command

php app/console cache:clear --env=prod --no-debug

I get the following error:

PHP Fatal error: Class 'Acme\MainBundle\AcmeMainBundle' not found in /var/www/html/app/AppKernal.php on line 24

This is the in AppKernal.php

public function registerBundles()
{
    $bundles = array(
        ...
        new Acme\MainBundle\AcmeMainBundle(),
    );
    ...
}

It seems like there's a problem with the namespace?

like image 322
Jason Lin Avatar asked Jul 11 '13 02:07

Jason Lin


2 Answers

If you are getting a bundle not found error in Symfony, in composer.json, modify the psr-4 section under autoload section like this.

"autoload": {
    "psr-4": {
        "": "src/"
    },
},

By doing so, you don't have to explicitly add the new bundle namespaces when you create a new bundle.

like image 94
Praveesh Avatar answered Oct 25 '22 06:10

Praveesh


Got the same problem. I've just deleted my vendor folder

rm -rf vendor

and relaunch a composer update.. then everything was fine

composer update
like image 5
arnaudbey Avatar answered Oct 25 '22 07:10

arnaudbey