步骤:
- 安装 PHPUnit,参见http://www.phpunit.de/manual/3.7/en/installation.html
步骤:
- 到 http://windows.php.net/downloads/releases/archives/ 下载PHP,解压并重命名到为php5.x.x,进入php5.x.x目录
- 如果需要扩展,打开php.ini,设置 extension_dir = "ext" , 取消对应扩展的注释,并将PHP路径添加到path环境变量中。
- 打开cmd,进入php5.x.x目录,运行go-pear.bat
- 如果找不到go-pear.bat文件1、下载: http://pear.php.net/go-pear.phar 2、命令行下,在php目录下运行
php go-pear.pharPS:如果该命令报错,可能是没有将PHP路径添加到path环境变量中。可能是因为我没有安装PHP的IDE,所以一直没有配置它,偶然之间才想到可能要添加这个环境变量。
- 提示
Are you installing a system-wide PEAR or a local copy? (system|local) [system]
按回车确定
- 提示
1. Installation base ($prefix) : D:\path_to_your_php\php5.x.x2. Temporary directory for processing : D:\path_to_your_php\php5.x.x\tmp 3. Temporary directory for downloads : D:\path_to_your_php\php5.x.x\tmp 4. Binaries directory : D:\path_to_your_php\php5.x.x5. PHP code directory ($php_dir) : D:\path_to_your_php\php5.x.x\pear 6. Documentation directory : D:\path_to_your_php\php5.x.x\docs 7. Data directory : D:\path_to_your_php\php5.x.x\data 8. User-modifiable configuration files directory : D:\path_to_your_php\php5.x.x\cfg 9. Public Web Files directory : D:\path_to_your_php\php5.x.x\www 10. Tests directory : D:\path_to_your_php\php5.x.x\tests 11. Name of configuration file : D:\path_to_your_php\php5.x.x\pear.ini 12. Path to CLI php.exe : D:\path_to_your_php\php5.x.x 1-12, ‘all’ or Enter to continue:
确定无误,则按回车,输入数字则修改对应项。修改后,按回车进行安装。
- 生成环境变量PEAR_ENV.reg文件,双击导入注册表
- 此时,输入pear -V 查看版本信息,输入pear list 查看已安装的包
- 如果pear list查看没有 Image_GraphViz 包和 Log 包,则使用 pear install Log 安装Log,使用 pear install Image_GraphViz
- 安装 Image_GraphViz 时,如果提示不能包含Structures/Graph/Node.php,则
- 尝试set查看PHP_PEAR_*相关环境变量是否正确
- 尝试关闭cmd窗口,再打开,再pear install Image_GraphViz
- 尝试pear install Stuctures_Graph,再pear install Image_GraphViz
- 至此,pear list 应有
INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET: ========================================= PACKAGE VERSION STATE Archive_Tar 1.3.3 stable Console_Getopt 1.2.3 stable Image_GraphViz 1.3.0 stable Log 1.12.7 stable PEAR 1.9.0 stable Structures_Graph 1.0.2 stable XML_Util 1.2.1 stable
此时,使用 pear upgrade-all 即可升级所有的包。
按快捷键 Win + R
,输入cmd并回车。进入存放phpunit.phar的路径。输入 echo @php "%~dp0phpunit.phar" %* > phpunit.cmd
并回车。接着输入 phpunit --version
并回车。如果得到输出 PHPUnit x.y.z by Sebastian Bergmann and contributors.
则表示配置好了(如果有误,输入exit
并回车,重新来一遍)。
将PHPunit的路径添加到path路径变量中。