PHP 5.3中的依赖注入 [英] Dependency Injection in PHP 5.3

查看:64
本文介绍了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.

我正在寻找一个积极开发和维护的DI容器。我发现了Crafty作为替代方案,可以将依赖项与XML,YAML,数组或以编程方式结合在一起。

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.

DI容器不应与功能完善的框架紧密结合,我们正在寻找一种简单且可插入的东西,并尽可能减少麻烦。

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.

推荐答案

由于人们似乎喜欢我的评论,因此将其发布为答案。我没有经验,但是我知道Symfony依赖注入库。它应该与框架的其余部分分离,并且看起来非常灵活。在 Symfony组件中进行检查。

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.

我还认为 Substrate 看起来还不错。根据作者的说法,它也具有生产经验,这总是很好的。

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

这篇关于PHP 5.3中的依赖注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆