I'm currently facing an important issue when i want to run any "php bin/console" command:
Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#29
#message: """
Attempted to load class "Kernel" from namespace "App".\n
Did you forget a "use" statement for "Symfony\Component\HttpKernel\Kernel"?
"""
#code: 0
#file: "./bin/console"
#line: 41
}
2020-06-11T15:43:20+00:00 [critical] Uncaught Error: Class 'App\Kernel' not found
While my Kernel.php class is normally defined in src/Kernel.php
I am working with Symfony 5
I manage to solve my issue performing 3 successive actions :
delete "vendor" folder (I saved it in another folder just in case)
delete "cach-dev" folder
run "composer update" command
Hope it can help other people to solve their issue
Related
I'm currently facing an important issue when i want to run any "php bin/console" command:
Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#29
#message: """
Attempted to load class "Kernel" from namespace "App".\n
Did you forget a "use" statement for "Symfony\Component\HttpKernel\Kernel"?
"""
#code: 0
#file: "./bin/console"
#line: 41
}
2020-06-11T15:43:20+00:00 [critical] Uncaught Error: Class 'App\Kernel' not found
While my Kernel.php class is normally defined in src/Kernel.php
I am working with Symfony 5
I manage to solve my issue performing 3 successive actions :
delete "vendor" folder (I saved it in another folder just in case)
delete "cach-dev" folder
run "composer update" command
Hope it can help other people to solve their issue
I'm using Symfony 4.4 on a project and I need to use stfalcontinymce. Since I'm on SF4 I need the version 2.4. So I did this:
composer require stfalcon/tinymce-bundle=2.4
But then I get this error:
!! 11:03:44 CRITICAL [php] Uncaught Error: Class 'Twig_Extension' not found ["exception" => Error { …}]
!!
!! In StfalconTinymceExtension.php line 13:
!!
!! Attempted to load class "Twig_Extension" from the global namespace.
!! Did you forget a "use" statement?
Someone told me that it's because this version doesn't get along with Twig 3 so I need to downgrade my Twig version. I then did this to downgrade Twig:
composer require twig/twig=2
But then I get this error:
13:14:07 CRITICAL [php] Uncaught Error: Call to undefined method Twig\Environment::registerUndefinedTokenPa
rserCallback() ["exception" => Error { …}]
!!
!! In srcApp_KernelDevDebugContainer.php line 2040:
!!
!! Attempted to call an undefined method named "registerUndefinedTokenParserCallback" of class "Twig\Environm ent".
!! Did you mean to call e.g. "registerUndefinedFilterCallback" or "registerUndefinedFunctionCallback"?
I tried adding in composer.json
"twig/extensions": "*"
Then composer install, then running the command:
composer require stfalcon/tinymce-bundle=2.4 -W
And I get this error:
!! 13:49:04 CRITICAL [php] Uncaught Error: Call to undefined method
Twig\Environment::registerUndefinedTokenParserCallback() ["exception" => Error { …}]
!!
!! In srcApp_KernelDevDebugContainer.php line 2045:
!!
!! Attempted to call an undefined method named "registerUndefinedTokenParserCallback" of class "Twig\Environment".
!! Did you mean to call e.g. "registerUndefinedFilterCallback" or "registerUndefinedFunctionCallback"?
I'm really lost here. Can someone help? thanks
Your executed commands don't seem to be possible on my system at all since there will be version constraint conflicts.
Instead of restricting to one version for your dependencies, you should use a constraint.
Your require in composer.json may contain something like the following
"twig/twig": "^2",
"stfalcon/tinymce-bundle": "2.4.*",
"twig/extra-bundle": "^2"
The constraints are explained here. But the ^2 basically means >= 2.x.x and < 3.0.0
For the tinymce bundle I used the above because of the this GitHub issue
Furthermore twig/extensions seems to be deprecated, and this GitHub issue mentions twig/extra-bundle which is needed and may be its replacement.
I have updated my system to from Symfony 3.2.x to Symfony 3.3.x and now I cam getting this error for every bundle in my application:
Attempted to load class "XXXXXXXXPublicBundle" from namespace "XXXXXXXX\PublicBundle".
Did you forget a "use" statement for another namespace?
In my PublicBundle I am using the namespace:
namespace XXXXXXXX\PublicBundle;
When I try and run php composer.phar update I get this error too:
Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "XXXXXXXXPublicBundle" from namespace "XXXXXXXX\PublicBundle".
What is going on - I have no clue what to do. Any assistance?
I have an exiting project in Symfony running on windows. Now I moved it to my laptop which runs Ubuntu 16.04. But when I try to do app/console it says that class was not found in AppKernel.
Here is the actual error message.
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "PimSecurityBundle" from namespace "Pim\SecurityBundle".
Did you forget a "use" statement for another namespace? in /var/www/html/pim/app/AppKernel.php:34
Stack trace:
0 /var/www/html/pim/app/bootstrap.php.cache(2675): AppKernel->registerBundles()
1 /var/www/html/pim/app/bootstrap.php.cache(2497): Symfony\Component\HttpKernel\Kernel->initializeBundles()
2 /var/www/html/pim/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(70): Symfony\Component\HttpKernel\Kernel->boot()
3 /var/www/html/pim/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(123): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
4 /var/www/html/pim/app/console(27): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
5 {m in /var/www/html/pim/app/AppKernel.php on line 34
I already run composer update several times, remove my vendor and update but nothing works.
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
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...
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.)
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.