Dependency Injection Component v4.0

Nicolas Grekas (17.Nov.2017 at 13:30, 40 min)
Talk at SymfonyCon Cluj 2017 (English - US)

Rating: 5 of 5

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.

Who are you?

Claim talk

Talk claims have been moved to the new Joind.in site.

Please login to the new site to claim your talk

 
Comments closed.

Comments

Rating: 4 of 5

17.Nov.2017 at 14:17 by Timo Bakx (25 comments) via Web2 LIVE

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.

Rating: 5 of 5

17.Nov.2017 at 14:21 by Jeff Sacco (7 comments) via Web2 LIVE

This is how a talk should be. He knew his audience, clear and concise slides, great speaker.

Rating: 5 of 5

17.Nov.2017 at 15:26 by Patrick Reimers (17 comments) via Web2 LIVE

Great talk.
He really could explain the changes in the DI component.
Too bad there wasn't more time.

Speaker comment:

17.Nov.2017 at 16:57 by Nicolas Grekas (6 comments) via Web2 LIVE

> 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 :)

Rating: 5 of 5

17.Nov.2017 at 20:08 by Steve Winter (51 comments) via Web2 LIVE

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.

Rating: 5 of 5

18.Nov.2017 at 16:08 by Florian Strübe (5 comments) via Web2 LIVE

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!

Rating: 5 of 5

19.Nov.2017 at 22:08 by Mateusz Deszert-Kłosowski (24 comments) via Web2 LIVE

Good presentation of new features. Liked sli.do idea as well.

Rating: 5 of 5

20.Nov.2017 at 03:14 by Romain Gautier (93 comments)

Awesome new features/talk !

Rating: 5 of 5

21.Nov.2017 at 08:14 by Andreas B. (26 comments) via Web2 LIVE

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.

Rating: 5 of 5

23.Nov.2017 at 01:30 by Jose Monagas (10 comments) via Web2 LIVE

One of the best improvements in Symfony nowadays and perfectly explained by Nicolas. Congratulations!

© Joind.in 2018