Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony2 bundle autoloading failed

Tags:

symfony

bundle

I happen to get all the symfony problems of the creation...

I want to create a new project.

I copy the 'symfony2' folder, rename it then:

 php app/console generate:bundle

It says:

  Generating the bundle code: OK
  Checking that the bundle is autoloaded: FAILED
  Confirm automatic update of your Kernel [yes]? 
  Enabling the bundle inside the Kernel: OK
  Confirm automatic update of the Routing [yes]? 
  Importing the bundle routing resource: FAILED

  The command was not able to configure everything automatically.  
  You must do the following changes manually.                      

  - Edit the composer.json file and register the bundle
  namespace in the "autoload" section:

  Bundle MddevPsavBundle is already imported.

Why is this? When I did not have that problem last time I have done the same command?

How can I solve this exactly? and what shall I add exactly into that composer.json file ??

I have tried something but I get:

  Fatal error: Class 'Mddev\PsavBundle\MddevPsavBundle' not found in
  /var/www/projetQ/app/AppKernel.php on line 22
like image 492
Matoeil Avatar asked Mar 31 '26 15:03

Matoeil


2 Answers

If you are getting the problem:

The command was not able to configure everything automatically.  
You must do the following changes manually.

Which then tells you to:

- Edit the composer.json file and register the bundle
namespace in the "autoload" section:

Assuming you have followed the bundle name conventions correctly, then you will need to:


Add your new bundle to the composer.json file

"autoload": {
    "psr-0": {
        "currentbundle\\": "src/",
        "YOURNEWBUNDLE\\": "src/",            
    }
}

You then need to run install on composer again

composer -n install --dev

You should then have both of the bundles autoloaded

like image 90
Andrew Atkinson Avatar answered Apr 02 '26 14:04

Andrew Atkinson


Seems that your bundle namespace doesn't follow conventions: http://symfony.com/doc/current/cookbook/bundles/best_practices.html#bundle-name

You should rather use Mddev\Bundle\MddevPsavBundle or Mddev\MddevPsavBundle as a bundle namespace.

like image 37
Jakub Zalas Avatar answered Apr 02 '26 13:04

Jakub Zalas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!