Ubuntu,zend框架和PHPUnit-测试注意:PHPUnit没有在include_path中找到,因此不会创建任



我在我的ubuntu上安装了Zend Framework。我刚刚安装了PHPUnit。我可以在终端使用它。一切都很好。我已经在apache和php CLI使用的php.ini中手动将PHPUnit路径添加到include_path中。Apache重新启动时没有任何问题。

但如果我使用:zf.sh create project myproject,我会得到信息:Testing Note: PHPUnit was not found in your include_path, therefore no testing actions will be created.

我想我测试了我在互联网上找到的所有解决方案。。。请帮帮我。

首先安装PHPUIT,然后将PHPUNIT库放入php include路径。在主目录中创建一个名为".zf.ini"的文件,并添加一行php包含路径php.include_path=".:/usr/lib/php/pear"

为了使zf命令的phpunit文件自动加载,请在zf.php文件中添加以下函数

// For solving loading issue of PHPUNIT classs from pear folder
spl_autoload_register(function($class)
{   
        $file = str_replace('_','/',$class.'.php');
        //Suppress errors in case it can't find the file.
        @include_once $file;
});

我希望这能解决你的问题。

Zend_Tool有时似乎不尊重包含路径。试着把这样的东西放在你的~/.zf.ini 中
php.include_path = "/usr/share/php:/path/to/zf/library"

好吧,也许这会帮助像我这样有同样情况的人。我无法解决这个问题,所以我从头开始。我为Ubuntu 11.10做了新的安装。然后,我使用本教程安装了MySQL、Apache、PHP和其他PHP包。接下来,我使用本文安装了PHPUnit。一切都很好。所以我开始寻找安装Zend Framework的最佳方式。我发现了很多文章、博客等,但都不起作用。

所以我从zend站点下载了这个框架,并对它进行了解压缩。在zf目录中,我为zend-bin更改了bin的名称,为zend更改了库的名称。然后,我将zend-bin复制到/usr/local,将zend复制到/usr/share.php,并创建到us-zf命令的链接(ln -s /usr/local/zend-bin/zf.sh /usr/bin/zf)。接下来,我在php.ini中为CLI更改了include_path,添加了/usr/share/php/zend-path。

现在一切都正常了。希望它能有所帮助。

最新更新