8000 [RFC][DependencyInjection][HttpKernel] Kernel as a service by ro0NL · Pull Request #19606 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RFC][DependencyInjection][HttpKernel] Kernel as a service #19606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed

[RFC][DependencyInjection][HttpKernel] Kernel as a service #19606

wants to merge 7 commits into from

Conversation

ro0NL
Copy link
Contributor
@ro0NL ro0NL commented Aug 12, 2016
Q A
Branch? "master"
Bug fix? yessish
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? not yet
Fixed tickets #18563, #19586
License MIT
Doc PR reference to the documentation PR, if any

TLDR; This allows for ready to use service objects during container compilation~~.~~, and now also extension loading.

How i did it;
After my first attempt i think i got a viable solution now that allows to work with safe service objects during container compilation, basically it introduces a ServiceAwareDefinition; a service definition aware of its service object, which is allowed for in ContainerBuilder::get. It's bulletproof, in a way it's developer responsibility to keep the definition+service in sync. This also plays well with synthetic services perhaps...

This is feature 1, which can be a separate PR. Feature 2 is introducing the kernel as a service (aware definition). For now i think it's good mainly because of pragmatic reasons; we can fix bugs in a normal way. In the long run it allows for separation of concerns; kernel/bundles in the ecosystem (booting, building, terminating) and kernel/bundles in userland (paths, names, utility).

The second concept is far from ready, but what about this approach?

@GuilhemN
Copy link
Contributor
GuilhemN commented Aug 13, 2016

What about instead removing the concept of obsolete definitions ? Imo it could be considered as a bug fix as this behavior is clearly not expected.

@ro0NL
Copy link
Contributor Author
ro0NL commented Aug 13, 2016

Marking a definition as obsolete when the same id is overwritten by a synthetic service object sounds logical to me. I think the "problem" is a synthetic service needs to be tight to a definition id... im not sure we wanna change that, i guess this is by design.

But yeah, setting the kernel instance along with a synthetic definition, in early phase could work also for feature 2, now that i think of it. However feature 1 for would still be useful as it allows for non-synthetic definitions + service object to be set.

edit: Btw.. it becomes real quirky in MergeExtensionConfigurationPass (see my first attempt) where synthetic services are vanished anyway during extension loading ;-)

edit2: yeah extensions are still an issue 😭

$container = $this->buildContainer();
$container->setDefinition('kernel_as_a_service', $serviceDefinition);
Copy link
Contributor
@ogizanagi ogizanagi Aug 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit: Btw.. it becomes real quirky in MergeExtensionConfigurationPass (see my first attempt) where synthetic services are vanished anyway during extension loading ;-)
#19606 (comment)

If you want to use this service in an extension, you'll still have to do quirky things in MergeExtensionConfigurationPass as in your first attempt to make it available in the $tmpContainer passed to the ExtensionInterface::load method, right ?
Or perhaps you're only targeting compiler passes now ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it ;-)... however there are some design choices to be made.

} catch (ServiceNotFoundException $e) {
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
return;
if ($this->compiled && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
Copy link
Contributor Author
@ro0NL ro0NL Aug 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For BC, however i tend to debug unknown id's before state. Just throwing here would be fine by me.

@ro0NL
Copy link
Contributor Author
ro0NL commented Aug 13, 2016

This is also highly related to #19192 i guess.

@ro0NL ro0NL changed the title [WIP][DependencyInjection][HttpKernel] Kernel as a service [RFC][DependencyInjection][HttpKernel] Kernel as a service Aug 14, 2016
@ro0NL
Copy link
Contributor Author
ro0NL commented Aug 19, 2016

Favoring #19646

@ro0NL ro0NL closed this Aug 19, 2016
@ro0NL ro0NL deleted the http-kernel/kernel-as-a-service branch August 19, 2016 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0