Symfony3:致命错误:在 .\bin\console 中找不到“AppKernel"类 [英] Symfony3: Fatal error: Class 'AppKernel' not found in .\bin\console

查看:36
本文介绍了Symfony3:致命错误:在 .\bin\console 中找不到“AppKernel"类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚开始一个项目,我运行了 composer update 并在尝试清除缓存时遇到异常.

just started working on a project, I ran composer update and was greeted with a exception when trying to clear cache.

当我尝试运行 php bin\console server:run 时,我收到以下消息:

When I try to run php bin\console server:run I am greeted with this message:

php bin\console server:run
PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class 'AppKernel' not found in CoreBundle\bin\console:27
Stack trace:
#0 {main}
  thrown in CoreBundle\bin\console on line 27

Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class 'AppKernel' not found in CoreBundle\bin\console on line 27

Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class 'AppKernel' not found in CoreBundle\bin\console on line 27

Call Stack:
    0.0112     427536   1. Symfony\Component\Debug\ErrorHandler->handleException() CoreBundle\vendor\symfony\symfony\src\Symfony\Component\Debug\ErrorHandler.php:0

推荐答案

另一种可能性很大,特别是如果项目是从 v2.7 项目(或之前)更新的,则 Composer 不知道 AppKernel.现在最好的做法是不要手动要求/包含文件,(因此这些行从 web/app_*.phpbin/console.php 中删除).而是让它自动加载.但是,这需要 Composer 中的一行才能找到.只有 Composer 自动加载器会被手动包含,然后可以加载其他所有内容.

Another strong possibility, particularly if the project has been updated from a v2.7 project (or before) is that the AppKernel is just not known to Composer. It is now best practice to not manually require/include the file, (so those lines are removed from web/app_*.php, and bin/console.php). but instead have it autoloaded. However, this requires a line in Composer so that it can be found. Only the composer autoloader would ever be included manually, which can then load everything else.

"autoload": {
    "files": ["app/AppKernel.php"],
    "psr-4": {  // etc...

这篇关于Symfony3:致命错误:在 .\bin\console 中找不到“AppKernel"类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆