I’m actually upgrade my symfony 3.4 project to symfony 4.0. After clone bundles from my gitlab repositories with composer update, I have an error :
ClassNotFoundException Attempted to load class "Kernel" from namespace "App". Did you forget a "use" statement for "SymfonyComponentHttpKernelKernel"? in index.php (line 32)
Ok…. Easy… go index.php line 32… but, Kernel is load with AppKernel, so any idea why I have this error or where I can search?
Thank you for your help.
index.php
use AppKernel; use SymfonyComponentDebugDebug; use SymfonyComponentDotenvDotenv; use SymfonyComponentHttpFoundationRequest; require __DIR__.'/../vendor/autoload.php'; // The check is to ensure we don't use .env in production if (!isset($_SERVER['APP_ENV'])) { (new Dotenv())->load(__DIR__.'/../.env'); } if ($_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev'))) { umask(0000); Debug::enable(); } // Request::setTrustedProxies(['0.0.0.0/0'], Request::HEADER_FORWARDED); $kernel = new Kernel($_SERVER['APP_ENV'] ?? 'dev', $_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev'))); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response);
And in the “src” directory, I have the Kernel.php file
namespace App; use SymfonyBundleFrameworkBundleKernelMicroKernelTrait; use SymfonyComponentConfigLoaderLoaderInterface; use SymfonyComponentDependencyInjectionContainerBuilder; use SymfonyComponentHttpKernelKernel as BaseKernel; use SymfonyComponentRoutingRouteCollectionBuilder; class Kernel extends BaseKernel { use MicroKernelTrait; const CONFIG_EXTS = '.{php,xml,yaml,yml}'; .....
Advertisement
Answer
Symfony 4
uses the folder App
for autoload psr-4
. I tried to change it, but it didn’t work out. Check the namespace at your composer.json
file, in the property autoload
and then psr-4
.
Maybe you changed the default one.