Skip to content

Commit fa1a626

Browse files
committed
feature #40513 [Runtime] make GenericRuntime ... generic (nicolas-grekas)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Runtime] make GenericRuntime ... generic | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This PR will allow #40436 to move to https://github.com/symfony/psr-http-message-bridge For the record, it builds on a prototype I wrote almost one year ago at https://github.com/tchwork/bootstrapper. This PR makes the `GenericRuntime` implementation able to auto-discover runtime implementations for specific types. It uses the autoloader for the discovery: when a closure-app requires or returns a type `Vendor\Foo`, it will use a convention and check if the class `Symfony\Runtime\Vendor\FooRuntime` exists. If yes, it will use it to resolve the corresponding type. Such runtime classes have to extend `GenericRuntime` so that they can use the protected API it provides. This requirement is aligned with the fact that the very convention proposed here is an implementation detail that works when using a `GenericRuntime` as the main runtime (This behavior can be overridden by providing explicit entries in the new `runtimes` option when booting the `GenericRuntime`.) `SymfonyRuntime` can be used as both the main runtime or a type-specific runtime: - when used as the main runtime, it configures the typical global-state for Symfony and has a fast codepath for Symfony types, while still being generic. - it can also be used in another runtime as a way to resolve Symfony types (would typically be useful to #40436 for running Console apps in a PSR-based web app.) Commits ------- 33e371e24d [Runtime] make GenericRuntime ... generic
2 parents 79bcf59 + 9c94c4f commit fa1a626

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Resources/config/services.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
use Symfony\Component\HttpKernel\KernelEvents;
3939
use Symfony\Component\HttpKernel\KernelInterface;
4040
use Symfony\Component\HttpKernel\UriSigner;
41+
use Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner;
42+
use Symfony\Component\Runtime\Runner\Symfony\ResponseRunner;
4143
use Symfony\Component\Runtime\SymfonyRuntime;
4244
use Symfony\Component\String\LazyString;
4345
use Symfony\Component\String\Slugger\AsciiSlugger;
@@ -79,6 +81,8 @@ class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES : []
7981
service('argument_resolver'),
8082
])
8183
->tag('container.hot_path')
84+
->tag('container.preload', ['class' => HttpKernelRunner::class])
85+
->tag('container.preload', ['class' => ResponseRunner::class])
8286
->tag('container.preload', ['class' => SymfonyRuntime::class])
8387
->alias(HttpKernelInterface::class, 'http_kernel')
8488

0 commit comments

Comments
 (0)