Reputation: 669
I have been working on migrating my Symfony 3.x project to the latest Symfony 4.x version. What I did was create a fresh install of Symfony 4.x and have been moving my bundle to Symfony 4 as a the main App namespace (renamed all my namespaces and use). I followed the correct folder structure in the Symfony 4 docs, but I obviously missed something.
When I try to do "bin/console server:run", I am presented with this error:
php bin/console server:run
Fatal error: Uncaught
Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load
class "Kernel" from namespace "App".
Did you forget a "use" statement for "Symfony\Component\HttpKernel\Kernel"?
in C:\wamp\www\DBViewer\bin\console:37
Stack trace:
#0 {main}
thrown in C:\wamp\www\DBViewer\bin\console on line 37
I checked line 37 in the console and all it was:
$kernel = new Kernel($env, $debug);
I've compared the the bin/console from my working Symfony 4 app to this Symfony 4 app, and it is the same. Any ideas what could be causing this?
Upvotes: 0
Views: 96
Reputation: 59
Verfify your composer.json file. In Symfony 3.4 it used to be:
"autoload": {
"psr-4": {
"AppBundle\\": "src/AppBundle"
},
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
while in Symfony 4 it is simply:
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
In Symfony 4 your AppKernel.php must be directly in "src/" folder and not in "app/".
Hope this helps.
Upvotes: 1