symfony / symfony-docs

The Symfony documentation
https://symfony.com/doc
Other
2.14k stars 5.1k forks source link

[FrameworkBundle] Simplified the MicroKernelTrait setup #19977

Closed javiereguiluz closed 2 weeks ago

javiereguiluz commented 3 weeks ago

Fixes #19975.

yceruto commented 3 weeks ago

Javier thanks for opening this PR so quickly :)

I was wondering if we could simplify the example even more by referencing the runtime autoload file instead and replace this code:

$kernel = new Kernel('dev', true);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

with this other:

return static function (array $context) {
    return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
}

wdyt?

javiereguiluz commented 3 weeks ago

I like your proposal Yonel. I updated the PR with your changes. Thanks for the review.