Creating a Symfony 3 package always calls "Edit composer.json file"

Hi, I learn symfony, and every time I use the command "php bin / console generate: bundle" to create a package, although I leave everything by default, I keep getting this error:

The team could not configure everything automatically. You need to make the following changes manually. Edit the composer.json file and register the set namespace in the "startup" section:

I saw here in stackoverflow that this problem occurs when you try to put a package in a file other than src, but this is not the way I told you, I leave everything by default; I mean, I just entered the name of the package, and then keep clicking until the process is complete. Can someone tell me what I am doing wrong? What reason? Thanks

+4
source share
3 answers

Change composer .json:

Before:

"autoload": { "psr-4": { "AppBundle\\": "src/AppBundle", }, "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] }' 

After:

 "autoload": { "psr-4": { "AppBundle\\": "src/AppBundle", "NameofBundle\\": "src/NameofBundle" }, "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] }, 

Then run:

 composer dump-autoload 
+14
source

Just change composer.json:

Before:

 "psr-4": { "AppBundle\\": "src/AppBundle" }, 

After:

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

And finally run:

 composer dump-autoload 
+17
source

I also had this problem in symfony 3.4.4. I use this role in composer.json And then the problem was fixed.

for

 "autoload": { "psr-4": { "AppBundle\\": "src/AppBundle" }, "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] }, 

after

 "autoload": { "classmap": [ "app/AppKernel.php", "app/AppCache.php" ], "psr-4": { "": "src/" } }, 

and then cmd $ composer dump-autoload.

+1
source

Source: https://habr.com/ru/post/1273869/


All Articles