window中用pear安装phpunit

来源:互联网 发布:蔡洋 知乎 编辑:程序博客网 时间:2024/05/10 09:31

window中用pear安装phpunit

1.安装pear
1)在命令行中,进入php安装目录,运行:

go-pear.bat

(可能出现报错情况)
2)下载go-phar.bat至php安装目录,运行:

php go-pear.phar

3)双击刚产生的PEAR_ENV.reg ,导入注册表
4)此时pear应该安装成功了,更新至最新版本:

pear upgrade

(这一步挺重要的,phpunit貌似是使用pear的1.9.x才能安装)
2.安装phpunit:
1)添加phpunit的频道

pear channel-discover pear.phpunit.depear channel-discover components.ez.nopear 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目录复制到your path/php/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