2017-08-19 87 views
1

我使用Symfony版本2.8。生成新捆绑包时出现以下错误。Symfony生成新的Bundle无法自动更新自动加载

php bin/console generate:bundle --namespace=FrontBundle --no-interaction 

然后控制台告诉我这导致

捆绑代

生成一个样品捆骨架为:

error screen shot

我使用此命令生成一个新的软件包C:\ xampp \ htdocs \ TRC \ app /../ src/FrontBundle 创建。\应用/../的src/FrontBundle/ 创建。\应用/../的src/FrontBundle/FrontBundle.php 创建。\应用/../的src/FrontBundle /控制器/ 创建。\应用程序/ ../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/ 已创建。\ app /../ src/FrontBundle/Resources/config/services.yml 检查捆绑软件是否自动加载 FAILED 在C:\ xampp \ htdocs \ TRC \ app \ AppKernel.php中启用软件包 已更新。\ app \ AppKernel.php 确定 从C:\ xampp \ htdocs \ TRC \ app \ config \ routing.yml文件 已更新。\ app/config/routing.yml 确定 从C:\ xampp \ htdocs \ TRC \ app \ config \ config.yml文件中导入bundle的services.yml更新了\\ \ app/config /config.yml 确定

该命令无法自动配置所有内容。
您需要手动进行以下更改。

编辑composer.json文件并注册了“自动加载”部分中的束 名称空间:

过程在17点19分48秒,退出代码0结束。 执行时间:719毫秒。

然后,添加一行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" 
     ] 
    }, 
#......... 

最后,我再次使用控制台翻斗自动加载,当我刷新页面,我得到了同样的错误。

我试图清除缓存并强制浏览器刷新。

+0

重复:https://stackoverflow.com/questions/44946911/symfony3-classnotfoundexception-after-bundle-creation/44948820#44948820并与实际更新你的问题错误信息。没有人喜欢点击随机链接。 – Cerad

回答

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

或者更好:

"psr-4": { 
    "": "src/" 
} 
+0

我替换''psr-4“:{ ”AppBundle \\“:”src/AppBundle“, ”FrontBundle \\“:”src/FrontBundle“ },'by only'”psr-4“:{ “”:“src /” }'??? –

+0

@AlaaEddineChebil是的,那么你的src中的任何东西都会被自动加载。 – kunicmarko20

+0

我这样做,但问题仍然没有解决 –