You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #57408 [FrameworkBundle] Simpler Kernel setup with MicroKernelTrait (yceruto)
This PR was merged into the 7.2 branch.
Discussion
----------
[FrameworkBundle] Simpler Kernel setup with `MicroKernelTrait`
| Q | A
| ------------- | ---
| Branch? | 7.2
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Issues | -
| License | MIT
Minor improvements to create minimalistic Symfony apps with zero config (initially) + invokable controller using the Kernel class only:
```php
// index.php
<?php
require_once __DIR__.'/vendor/autoload_runtime.php';
// ...
class StripeWebhookEventSubscriber extends Kernel
{
use MicroKernelTrait;
#[Route('/', methods: 'GET')]
public function __invoke(Request $request, NotifierInterface $notifier): Response
{
// ...
return new Response('OK');
}
}
return static function (array $context) {
$kernel = new StripeWebhookEventSubscriber($context['APP_ENV'], (bool) $context['APP_DEBUG']);
return \PHP_SAPI === 'cli' ? new Application($kernel) : $kernel;
};
```
> [!NOTE]
> Ideal for one-file apps or workers.
**What exactly does this PR improve?**
* It makes the `config/` directory optional. Then you can add extension configs by redefining the `configureContainer()` method or by importing external files in `config/packages/*` as usual.
* It adds support for service arguments when an invokable controller is defined within the same kernel class (as shown in the example)
* Fall back to `yield new FrameworkBundle()` in `registerBundles()` method in case the `$this->getBundlesPath()` file does not exist.
What do you think?
Commits
-------
8176573134 Simpler kernel setup with MicroKernelTrait
0 commit comments