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

來源:互聯網
上載者:User

第4章 安裝PHPUnit

PHPUnit可以通過PHP擴充和程式庫(PEAE)獲得。PEAR是可重用PHP組件的架構和分發系統。安裝PHPUnit可以通過PEAR安裝程式命令獲得:

 

pear install PHPUnit2

 

根據PEAR的版本命名標準,適用於PHP5的PHPUnit包稱為PHPUnit2。PHPUnit是適用於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).

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.