Through training and consultancy, I’ve been dealing with Magento 2 projects, without actually having a single responsibility in them. However, while standing on the sideline, I’ve seen many examples of Magento 2 development gone wrong. For the major part, this deals with Dependency Injection – one of the fundamental principles of Magento 2 architecture. DI is meant to clean up the code, allowing for looser dependencies. However, when applied wrongly, the code can still become spaghetti code – I know Italians love pasta, but you can’t find the beginning and the end of the code, it means the code should be improved. Even worse, one attempt of the Magento core team to enforce better DI upon developers with the coming of Magento 2.1, was perceived by many third-party developers as an instability of Magento 2, which I think was wrong. My talk will, therefore, be about the proper ways to apply Dependency Injection in Magento 2. It will point out mistakes, to then give you the handles to improve your code.


Comments are closed.

David Manners at 09:26 on 12 Jun 2017

Nice talk on the do's and don'ts of DI in Magento2

John Hughes at 18:44 on 13 Jun 2017

One of my favourite talks of the day. Very well presented and cleverly delivered.

Not only were there some great advanced level tips provided, such as not using helpers, checking $context, composition over inheritance and object manager usage, but clear reasoning for why was given. Showing the 'wrong' way then the 'right' way was also a great touch.