r/PHPhelp • u/MrBaseball77 • May 30 '18
PHP Dependency Injection tutorials?
I need a tutorial on using Dependency Injection/IOC in PHP. We are going to build an API and want the output formatters to be "pluggable" meaning we may use DI to accomplish this. I don't know how to do DI in PHP and need some brushing up on it.
9
Upvotes
3
u/pernicat May 30 '18
If you want to understand the basic concepts behind DI I would recommend checking out PHP The Right Way.
If you want to play around with a simple barebones DI container try Pimple. It does not have fancy features (like autowiring) but it is super simple to learn and can help you understand some of the concepts. Most of the more advance DI containers seem to have complex configuration syntax that gets in the way of understanding how it all fits together.