Reply To: How Symfony/Laravel automatically autoload and instantiate required object?

#2557
MattBD
Guest

Last year I wrote a tutorial on how to write your own toy DI container, which you may find useful. It’s at https://matthewdaly.co.uk/blog/2019/02/02/creating-your-own-dependency-injection-container-in-php/

The end result isn’t something I’d be comfortable using in production, but it demonstrates how a DI container works in principle. Basically it just uses the Reflection API to resolve items, resolving any dependencies recursively.