PHP的控制容器反转?
我正在尝试用 PHP 编写 TDD 样式,而我最大的绊脚石之一(除了缺乏像样的 IDE)是我必须制作自己的 IoC 容器,才能正确注入所有模拟对象.
I am trying to code TDD style in PHP and one of my biggest stumbling blocks (other than lack of a decent IDE) is that I have to make my own hacked together IoC container just to inject all my mock objects properly.
有人在 PHP 中使用过 Ioc 容器吗?我所能找到的只是 PHP IOC on the ever-annoying phpclasses.org 而且它似乎几乎没有文档,也没有太多的追随者.
Has anyone used an Ioc container in PHP? All I've been able to find is PHP IOC on the ever-annoying phpclasses.org and it seems to have almost no documentation and not much of a following.
推荐答案
我玩过一些 PHP 的 DI 框架,但我没有在生产中使用过.有一些链接:
I played with some DI Frameworks for PHP, but I haven't used one in production. Have some links:
- http://www.stubbles.net/ 其中我认为是我尝试过的最老的
- http://php.xjconf.net/
- FLOW3 - 我相信这个会成为一个非常好的框架(它的测试版)
- http://www.stubbles.net/ which I think is the oldest I tried
- http://php.xjconf.net/
- FLOW3 - I belive this one will become a very nice framework (its beta right now)
你提到你会将它用于 TDD - 所以也许看看 PHP 中单元测试的依赖注入
You mentioned you would use it for TDD - so maybe have a look at Dependency Injection for Unit Tests in PHP
相关文章