PHPUnit袖珍指南-第四章 安装PHPUnit

4 安装PHPUnit

PHPUnit可以通过PHP扩展和程序库(PEAE)获得。PEAR是可重用PHP组件的框架和分发系统。安装PHPUnit可以通过PEAR安装程序命令获得:

 

pear install PHPUnit2

 

根据PEAR的版本命名标准,适用于PHP5PHPUnit包称为PHPUnit2PHPUnit是适用于PHP4的包,这在本书后面关于“在PHP4中使用PHPUnit”一章会提到。

 

安装只有,能够在本地的PEAR目录中找到PHPUnit的源代码,路径通常是/usr/lib/ php/PHPUnit2

 

尽管使用PEAR安装程序是PHPUnit唯一支持的安装方法,但你还是可以手工安装。要手工安装,参照以下做法:

1.        http://pear.php.net/package/PHPUnit2/download下载PHPUnit发布包,然后解压缩,确保目录在php.ini定义的include_path中。

2.        准备phpunit脚本

a.             pear-phpunit脚本改名为phpunit

b.             将脚本中所有的@php_bin@改名为PHP命令行解释器所在的目录(通常为/usr/bin/ php)。

c.             将此脚本拷贝到一个PATH环境变量所包含的目录中,并将文件属性改为可执行(chmod +x phpunit)

3.        PHPUnit2/ Runner/Version.php脚本中的所有@package_version@字符串替换为你所安装的PHPUnit版本(如2.3.0)。

 

--------------------------------------------------------------------------------------------------------------------

原文

Chapter 4. Installing PHPUnit

PHPUnit[1] is available from the PHP Extension and Application Repository (PEAR), [2] which is a framework and distribution system for reusable PHP components. It can be installed using the PEAR Installer:

 

[1] http://www.phpunit.de/

 

[2] http://pear.php.net/

 

       $ pear install PHPUnit2

 

 

 

Due to PEAR's version-naming standard, the PHPUnit package for PHP 5 is called PHPUnit2. PHPUnit is the name of the PHPUnit package for PHP 4 that is the topic of "PHPUnit for PHP 4," later in this book.

 

After the installation, you can find the PHPUnit source files inside your local PEAR directory; the path is usually /usr/lib/ php/PHPUnit2.

 

Although using the PEAR installer is the only supported way to install PHPUnit, you can install PHPUnit manually. For manual installation, do the following:

 

Download a release archive from http://pear.php.net/package/PHPUnit2/download and extract it to a directory that is listed in the include_path of your php.ini configuration file.

 

Prepare the phpunit script:

 

Rename the pear-phpunit script to phpunit.

 

Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/ php).

 

Copy it to a directory that is in your PATH and make it executable (chmod +x phpunit).

 

Replace the @package_version@ string in the PHPUnit2/ Runner/Version.php script with the version number of the PHPUnit release you are installing (2.3.0, for instance).

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值