沃梦达 / 编程问答 / php问题 / 正文

PHP的控制容器反转?

Inversion of Control Container for PHP?(PHP的控制容器反转?)

本文介绍了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:

  1. http://www.stubbles.net/ 其中我认为是我尝试过的最老的
  2. http://php.xjconf.net/
  3. FLOW3 - 我相信这个会成为一个非常好的框架(它的测试版)
  1. http://www.stubbles.net/ which I think is the oldest I tried
  2. http://php.xjconf.net/
  3. 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

这篇关于PHP的控制容器反转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:PHP的控制容器反转?

基础教程推荐