DEV Community

Joshua Johnson
Joshua Johnson

Posted on


PHP Dependency Injection The Easy Way

Hey guys,

About 6 or 7 years ago I wrote a little PHP library that ended up becoming the a core part of a framework I built out for a project I was working on. I wanted to have a good dependency injection engine for my project but was not happy with the DI's that were available at the time. So I decided to make a very simple DI engine that is easy to understand.

I just wanted to share it because it's been a while since I've shared it. If you're looking for a good DI engine for your next PHP project, this is a good solution.

I was thinking about moving it over to my Org ( and officially supporting it again. This will depend on if anyone else sees a need for it.

Future feature updates:

  • Add a put($className, $object) method that will allow you to put and override instances within the DI container.
  • Update the project to become part of the Fire family. Rename it to FireDI.
  • Add Unit Testing with FireTest.

What features do you need in a DI?

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.