Categories


Archives


Recent Posts


Categories


New Free Magento 2 Dependency Injection Reference

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

One common request over on my patreon slack is helping folks reason about some piece of functionality as-implemented in the Magento 2 core. This usually means looking for a particular dependency on a class, and then looking for that class’s dependency, and following this dependency chain back until we find the actual five lines of code we’re interested in.

Magento’s automatic constructor dependency injection means you can never be sure what dependencies the system is actually injecting, so these help sessions usually mean going on a grep safari through Magento’s di.xml files.

This is a common enough thing that this weekend I dusted off some shell scripts and pulled them together into a new website

https://m2-dependency-injection-lookup.pulsestorm.net/

This dependency injection reference will let you statically search through the hundreds of di.xml files across Magento versions looking for any reference to a particular type/symbol. For example, here’s every configured dependency for the Magento\Catalog\Model\Product class.

This is a soft launch — I might have more to say about this website later. If you’re still in the business of writing backend code for Magento 2 give things a look over. If you see areas where information needs to be corrected or features you like, let me know. This is my first Node.js backed website I’ve launched via Glitch.com so if something seems technically wrong it’s almost certainly me, not you.

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 9th November 2020

email hidden; JavaScript is required