Heim >Backend-Entwicklung >PHP-Tutorial > window顶用pear安装phpunit
window中用pear安装phpunit
1.安装pear
1)在命令行中,进入php安装目录,如我的目录D:\php\Zend\ZendServer\bin,运行:
go-pear
若出现以下错误:
phar "D:\php\Zend\ZendServer\bin\PEAR\go-pear.phar" does not have a signature
Warning: require_once(phar://go-pear.phar/index.php): failed to open stream: pha
r error: invalid url or non-existent phar "phar://go-pear.phar/index.php" in D:\
php\Zend\ZendServer\bin\PEAR\go-pear.phar on line 1236
解决方法:打开php.ini文件,在最后一行加上:phar.require_hash = Off
4)此时pear应该安装成功了,更新至最新版本:
pear upgrade-all
(这一步挺重要的,phpunit貌似是使用pear的1.9.x才能安装)
2.安装phpunit:
1)添加phpunit的频道
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
2)安装:
pear install phpunit/PHPUnit
若出现此错误:
Fatal error:require_once():Failed opening required ‘Structures/Graph.php’
解决方法如下,下载此压缩包:
http://download.pear.php.net/package/Structures_Graph-1.0.3.tgz
解压并把Structures目录复制到D:\php\Zend\ZendServer\bin\PEAR下
若出现:
could not extract the package.xml file
Error:cannot download “phpunit/XXXX”
可能是pear下载目录的路径有空格如:D:/program files/
解决方法如下:
pear config-set temp_dir "C:\tmp"
pear config-set download_dir "C:\tmp"
这里设置目录的路径无空格就行了,想设哪里到是无所谓。
最后测试下是否安装成功,cmd中运行:
phpunit
3、zendStudio8 整合phpunit
1)、首先在zend studio 中新建一个项目。
2)、在项目项目上右键 出现 Properties ,点击 Properties 在出现的框中选择 PHP Include Path -> Libraries -> Add Library ,选择PHPUnit 3.x 即可。