DEV Community

Joshua Johnson
Joshua Johnson

Posted on

1

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.

https://github.com/joshualjohnson/ulfberht

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 (https://github.com/ua1-labs) 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?

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay