要获取 PHPUnit,最简单的方法是下载 PHPUnit 的 PHP 档案包 (PHAR),它将 PHPUnit 所需要的所有必要组件(以及某些可选组件)捆绑在单个文件中:
要使用 PHP档案包(PHAR)需要有 phar 扩展。
要使用 PHAR 的 —self-update 功能需要有 openssl 扩展。
如果启用了 Suhosin 扩展,需要在 php.ini 中允许执行 PHAR:
suhosin.executor.include.whitelist = phar
如果要全局安装 PHAR:
$wget https://phar.phpunit.de/phpunit.phar$chmod +x phpunit.phar$sudo mv phpunit.phar /usr/local/bin/phpunit$phpunit --versionPHPUnit x.y.z by Sebastian Bergmann and contributors.
也可以直接使用下载的 PHAR 文件:
$wget https://phar.phpunit.de/phpunit.phar$php phpunit.phar --versionPHPUnit x.y.z by Sebastian Bergmann and contributors.
整体上说,在 Windows 下安装 PHAR 和手工在 Windows 下安装 Composer 是一样的过程:
下载地址:https://phar.phpunit.de/
- 为 PHP 的二进制可执行文件建立一个目录,例如
C:\bin - 将
;C:\bin附加到PATH环境变量中(相关帮助) - 下载 https://phar.phpunit.de/phpunit.phar 并将文件保存到
C:\bin\phpunit.phar - 打开命令行(例如,按 Windows+R » 输入
cmd» ENTER) - 建立外包覆批处理脚本(最后得到
C:\bin\phpunit.cmd):C:\Users\username>cd C:\binC:\bin>echo @php "%~dp0phpunit.phar" %* > phpunit.cmdC:\bin>exit - 新开一个命令行窗口,确认一下可以在任意路径下执行 PHPUnit:
C:\Users\username>phpunit --versionPHPUnit x.y.z by Sebastian Bergmann and contributors.
本文作者:
艾瑞可erik
本文链接: https://erik.xyz/2017/06/29/php-zhong-dan-yuan-ce-shi-an-zhuang-phpunit-win-linux/
版权声明: 本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。转载请注明出处!
本文链接: https://erik.xyz/2017/06/29/php-zhong-dan-yuan-ce-shi-an-zhuang-phpunit-win-linux/
版权声明: 本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。转载请注明出处!