简体   繁体   中英

Dependency Injection in PHP 5.3

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.

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.

铲斗似乎符合您的要求。

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM