Talk in English - US at SymfonyCon Cluj 2017
Track Name:
Advanced
View Slides: https://speakerdeck.com/nicolasgrekas/dependency-injection-component-v4-dot-0-symfonycon-cluj-2017
Short URL: https://joind.in/talk/44115
(QR-Code (opens in new window))
The Dependency Injection component is one of the central pieces of any Symfony applications since version 2.0. Starting this winter, it has gained many new features that were needed to build the new Symfony 4 experience around Flex. While used extensively in core, can you leverage them in your own apps? Can you create a lazy iterator in Yaml? A scoped service locator? Configure auto-configuration? During this talk, I'll tell you about the new tags, interfaces or annotations that allow building powerful services. The goal: making your apps always more expressive, thus maintainable.
Comments
Comments are closed.
Great talk, too bad there was more information than time. I'd love to hear more about the changes in the DI component.
Speaker was clear and excited to talk. It was a pleasure to listen to this talk.
This is how a talk should be. He knew his audience, clear and concise slides, great speaker.
Great talk.
He really could explain the changes in the DI component.
Too bad there wasn't more time.
> If you have 2 services implementing same interface, why do you suggest to wire them thru the interface but not directly? This way you don't need to put an alias
but your code should not target wiring! your code should target SOLID principles! which means following the LSP principle, so coding against abstractions.
> Is it possible to use wildcard path specs in the config files (i.e. ../src/*/Controller)?
Yes, the entry is a glob pattern
> What is the overhead of using autowire vs getting services from container? Because it must involve Reflection...
None, Symfony's container is compiled
> Do the defaults apply to imported files as well?
no, defaults apply only to the current file
> Who want some beer tonight?
sure ;)
> What is the difference between service locator and container?
using Symfony v4 specific definitions to answer thuis question: a container is The container, ie the object that holds all services.
A service locator is a container that knows only about a short list of predeclared services (could be with a different id)
> Is it possible to extend the config of individual services with Annotations? Like setting one explicitly to public and/or add an alias
Using annotations to define DI config is not possible (it has been rejected several times as ppl/core-team were not convinced by it, but that's never a definitive answer ;-) )
> How to register a service from vendor/ to di?
using regular DI configuration. But if a vendor needs a DI config, then make that config a Flex recipe so that the vendor package is made easy to install
> Do we have to write down service spec when creating factory pattern classes or DI v4 will automatically do the work for us?
yes, factories cannot be automated. But if you think of Doctrine repositories, v1.8 of the DoctrineBundle provides a new base class repository that works with autowiring.
> Can I use patterns or wildcards in the resources param in services yml?
yes you can! (and it's recursive when defining services)
> How are tagged services injected into class? Array in constructor?
as iterator objects (RewindableGenerator class in DI component, but your should always use the "iterable" type hint, never this class directly)
> We have an additional sf event dispatcher in sulu when using autoconfig would the subscribers be called in both dispatcher. how could this be fixed?
advanced and new question, needs custom response, I don't what to give bad answer yet, community discussion needed
> When extending AbstractController is it really necessary implementing ServiceSubscriberInterface? Actually AbstractController already implements it
Correct, that was for the demo :)
Excellent presentation from the man behind the machine - next time please give him a (much) bigger room and twice as long so that we can get right into the details and the demos.
Good talk about the new DI component by its author. The depth of the presentation was alright for me, since he described all the new features or changes that have been made compare to the previous DI component. It barely fit into the time slot, but it was alright.
When I will upgrade, I'll have to get into all the details by myself anyway.
Good presentation skills! Thanks!
Good presentation of new features. Liked sli.do idea as well.
Awesome new features/talk !
Changes in the DIC are great, as was the presentation by Nicolas. Unfortunately, there wasn't enough time to go into detail for most of the changes, but given that it's an advanced track that's ok: you get an overview and then look up what you're interested in your own time.
One of the best improvements in Symfony nowadays and perfectly explained by Nicolas. Congratulations!