5

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

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

3 Answers 3

13

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...
Sign up to request clarification or add additional context in comments.

1 Comment

Nice, that solved that problem :P No I just need to tell it about my AppBundle :P
2

There are two possible reasons for this.

First your autoloader is trashed or can't find files

composer dump-autoload

Second reason could be, that your var directory isn't writable in which the cache file for symfony is placed. Just check the permissions. Also take a close look into the log files. Maybe it tells you what the real Problem is. (Like an issue with syntax etc.)

4 Comments

thanks for your anwer, all this is locally on my windows machine, so all folders should be writeable. The process dosn't get far enough to load the Logger, so nothing in log files... Composer dump-autoload didn't work either :/
did you check if the user the xampp (my guess) uses has write permissions to that specific directory?
It turned out to be composers autoload settings over in the accepted anser :)
Thank you. For me it was the writable var directory. Unfortunately the log files, Apache or Symfony, told me nothing. I was getting the error that AppKernel could not find my bundle classes whether I was trying to do a cache:warmup or loading a page via a controller.
0

For some reason, I had to explicitly add src/Kernel.php to autoload. So my composer.json autoload section became:

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

After adding this, running composer dump-autoload did the trick.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.