Symfony HTTPKernel Component raise a fatal error because of Config Component

439 Views Asked by At

I've got a fatal error when I try to simply use the HttpKernel Component.

Fatal error: Class 'Symfony\Component\Config\FileLocator' not found in /.../vendor/symfony/http-kernel/Config/FileLocator.php on line 23

All packages has been install via composer 1.8.x The setup is minimalist

PHP 5.6

symfony/dependency-injection          v3.4.27             Symfony DependencyInjection Component
symfony/event-dispatcher              v3.4.27             Symfony EventDispatcher Component
symfony/http-foundation               v3.4.27             Symfony HttpFoundation Component
symfony/http-kernel                   v3.4.27             Symfony HttpKernel Component
symfony/process                       v3.4.27             Symfony Process Component
symfony/yaml                          v3.4.27             Symfony Yaml Component

I do not want to install all symfony/symfony package.

The facts is that symfony/config is a "require-dev" dependency and seems not to be installed. What I usually understand is that require-dev installation is normally install when you just run composer install|update. Apparently not...

Follow the code below

use Symfony\Component\HttpKernel\Kernel as SymfonyKernel;
use Symfony\Component\HttpKernel\Config\FileLocator;

class MyKernel extends SymfonyKernel {

  public function boot() {
    // ...
    $this->iamOnError();
    // ...
  }

  public function iamOnError() {
    // @see SymfonyKernel::getContainerLoader
    $locator = new FileLocator($this);
  }

}
use App\MyKernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;

$kernel = new MyKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

My solution is to add "symfony/config" in the root composer.json... This is a kind weird...

So my question is why I've got this error (I know that symfony/config is not installed), or why symfony/config is not a "require" in composer.json for symfony/http-kernel component.

0

There are 0 best solutions below