Symfony 生成新包无法自动更新自动加载
Symfony Generate new Bundle Failed to auto update autoload
我使用 Symfony 2.8 版。生成新包时出现以下错误。
我使用此命令生成了一个新包:
php bin/console generate:bundle --namespace=FrontBundle --no-interaction
然后控制台显示这个结果
Bundle generation
Generating a sample bundle skeleton into C:\xampp\htdocs\TRC\app/../src/FrontBundle
created .\app/../src/FrontBundle/
created .\app/../src/FrontBundle/FrontBundle.php
created .\app/../src/FrontBundle/Controller/
created .\app/../src/FrontBundle/Controller/DefaultController.php
created .\app/../tests/FrontBundle/Controller/
created .\app/../tests/FrontBundle/Controller/DefaultControllerTest.php
created .\app/../src/FrontBundle/Resources/views/Default/
created .\app/../src/FrontBundle/Resources/views/Default/index.html.twig
created .\app/../src/FrontBundle/Resources/config/
created .\app/../src/FrontBundle/Resources/config/services.yml
Checking that the bundle is autoloaded
FAILED
Enabling the bundle inside C:\xampp\htdocs\TRC\app\AppKernel.php
updated .\app\AppKernel.php
OK
Importing the bundle's routes from the C:\xampp\htdocs\TRC\app\config\routing.yml file
updated .\app/config/routing.yml
OK
Importing the bundle's services.yml from the C:\xampp\htdocs\TRC\app\config\config.yml file
updated .\app/config/config.yml
OK
The command was not able to configure everything automatically.
You'll need to make the following changes manually.
Edit the composer.json file and register the bundle
namespace in the "autoload" section:
Process finished with exit code 0 at 17:19:48.
Execution time: 719 ms.
然后我在自动加载部分的 Composer.Json 添加一行:
#...
"autoload": {
"psr-4": {
"AppBundle\": "src/AppBundle",
"FrontBundle\": "src/FrontBundle"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"autoload-dev": {
"files": [
"vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
]
},
#.........
最后,我再次使用控制台转储自动加载,当我刷新页面时,我得到了同样的错误。
我已尝试清除缓存并强制浏览器刷新。
"psr-4": {
"AppBundle\": "src/AppBundle",
"FrontBundle\": "src/FrontBundle"
},
或更好:
"psr-4": {
"": "src/"
}
我使用 Symfony 2.8 版。生成新包时出现以下错误。
我使用此命令生成了一个新包:
php bin/console generate:bundle --namespace=FrontBundle --no-interaction
然后控制台显示这个结果
Bundle generation
Generating a sample bundle skeleton into C:\xampp\htdocs\TRC\app/../src/FrontBundle created .\app/../src/FrontBundle/ created .\app/../src/FrontBundle/FrontBundle.php created .\app/../src/FrontBundle/Controller/ created .\app/../src/FrontBundle/Controller/DefaultController.php created .\app/../tests/FrontBundle/Controller/ created .\app/../tests/FrontBundle/Controller/DefaultControllerTest.php created .\app/../src/FrontBundle/Resources/views/Default/ created .\app/../src/FrontBundle/Resources/views/Default/index.html.twig created .\app/../src/FrontBundle/Resources/config/ created .\app/../src/FrontBundle/Resources/config/services.yml Checking that the bundle is autoloaded FAILED Enabling the bundle inside C:\xampp\htdocs\TRC\app\AppKernel.php updated .\app\AppKernel.php OK Importing the bundle's routes from the C:\xampp\htdocs\TRC\app\config\routing.yml file updated .\app/config/routing.yml OK Importing the bundle's services.yml from the C:\xampp\htdocs\TRC\app\config\config.yml file updated .\app/config/config.yml OK
The command was not able to configure everything automatically.
You'll need to make the following changes manually.Edit the composer.json file and register the bundle namespace in the "autoload" section:
Process finished with exit code 0 at 17:19:48. Execution time: 719 ms.
然后我在自动加载部分的 Composer.Json 添加一行:
#...
"autoload": {
"psr-4": {
"AppBundle\": "src/AppBundle",
"FrontBundle\": "src/FrontBundle"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"autoload-dev": {
"files": [
"vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
]
},
#.........
最后,我再次使用控制台转储自动加载,当我刷新页面时,我得到了同样的错误。
我已尝试清除缓存并强制浏览器刷新。
"psr-4": {
"AppBundle\": "src/AppBundle",
"FrontBundle\": "src/FrontBundle"
},
或更好:
"psr-4": {
"": "src/"
}