Dependency Injection in PHP 5.3

2019-03-30 07:23发布

I am trying to tidy up an application, and have manually been doing Constructor Dependency Injection for a while.

This is a bit tedious, and I would like to start utilizing a Dependency Injection Container instead.

I am looking for an actively developed and maintained DI container. I have found Crafty as an alternative, which can wire together dependencies with XML, YAML, Arrays or programatically.

The DI container should not be tightly coupled with a full blown framework, we are looking for something simple and pluggable, with the least hassle possible.

Does anyone have a recommendation and why you chose the particular implementation? Thanks for reading.

3条回答
The star\"
2楼-- · 2019-03-30 07:46

You can also check out PHP-DI, it features dependency injection through annotations (@Inject) and minimal configuration.

It's very easy to use, and it integrates with Zend Framework very well (if ever you are using it).

(disclaimer: I do work on this framework)

查看更多
欢心
3楼-- · 2019-03-30 08:02

Since people seem to like my comment, I post it as an answer. I do not have experience of it, but i know of Symfony Dependency Injection library. It should be decoupled from the rest of the framework and it seems to be pretty flexible. Check it out at Symfony Components.

I also think Substrate looks pretty good. According to the author, it also has production experience, which is always good.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-03-30 08:04

Bucket seems to fit well with your requirements.

查看更多
登录 后发表回答