Windows上安裝PEAR, PHPUnit成功

來源:互聯網
上載者:User
Windows下安裝PEAR, PHPUnit成功

環境要求:

Windows + APMServ5.2.6/PHP5以上

安裝步驟:

1、Windows的開始 -> 運行 ->cmd

2、安裝命令

d:
cd D:\APMServ5.2.6\PHP
D:\APMServ5.2.6\PHP>go-pear.bat

?Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :? 敲擊斷行符號鍵 (Enter)

Below is a suggested file layout for your new PEAR installation.? To
change individual locations, type the number in front of the
directory.? Type ‘all’ to change all of them or simply press Enter to
accept these locations.

?1. Installation base ($prefix)?????????????????? : D:\APMServ5.2.6\PHP
?2. Temporary directory for processing??????????? : D:\APMServ5.2.6\PHP\tmp
?3. Temporary directory for downloads???????????? : D:\APMServ5.2.6\PHP\tmp
?4. Binaries directory??????????????????????????? : D:\APMServ5.2.6\PHP
?5. PHP code directory ($php_dir)???????????????? : D:\APMServ5.2.6\PHP\pear
?6. Documentation directory?????????????????????? : D:\APMServ5.2.6\PHP\docs
?7. Data directory??????????????????????????????? : D:\APMServ5.2.6\PHP\data
?8. User-modifiable configuration files directory : D:\APMServ5.2.6\PHP\cfg
?9. Public Web Files directory??????????????????? : D:\APMServ5.2.6\PHP\www
10. Tests directory?????????????????????????????? : D:\APMServ5.2.6\PHP\tests
11. Name of configuration file??????????????????? : D:\APMServ5.2.6\PHP\pear.ini

12. Path to CLI php.exe?????????????????????????? : D:\APMServ5.2.6\PHP\.

1-12, ‘all’ or Enter to continue:?? 輸入all

Installation base ($prefix) [D:\APMServ5.2.6\PHP] :
Temporary directory for processing [$prefix\tmp] :
Temporary directory for downloads [$prefix\tmp] :
Binaries directory [$prefix] :
PHP code directory ($php_dir) [$prefix\pear] :
Documentation directory [$prefix\docs] :
Data directory [$prefix\data] :
User-modifiable configuration files directory [$prefix\cfg] :
Public Web Files directory [$prefix\www] :
Tests directory [$prefix\tests] :
Name of configuration file [D:\APMServ5.2.6\PHP\pear.ini] :
Path to CLI php.exe [D:\APMServ5.2.6\PHP\.] :

一直斷行符號,即可

此時D:\APMServ5.2.6\PHP 會多出一個檔案 pws-php5isapi.reg ,雙擊,確定,關閉控制台視窗,新開啟一個cmd。

D:\APMServ5.2.6\PHP>pear -V
PEAR Version: 1.7.1
PHP Version: 5.2.6
Zend Engine Version: 2.2.0
Running on: Windows NT 5EC44E99C71645F 5.1 build 2600

ok,安裝成功,不過別高興的太早了,還有升級呢…不然無法安裝後續的PHPUnit!

?

安裝PHPUnit

D:\APMServ5.2.6\PHP>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.2.1?? stable
Log????????????? 1.11.5? stable
PEAR???????????? 1.9.0?? stable
Structures_Graph 1.0.3?? stable
XML_Util???????? 1.2.1?? stable

沒有以上安裝包的請你先安裝,比如你沒有安裝Image_GraphViz 和Log,請輸入以下指令:

D:\APMServ5.2.6\PHP>pear install Image_GraphViz
D:\APMServ5.2.6\PHP>pear install Log

安裝成功後,再輸入以下指令:

D:\APMServ5.2.6\PHP>pear upgrade-all

Will upgrade channel://pear.php.net/archive_tar
Will upgrade channel://pear.php.net/structures_graph
Will upgrade channel://pear.php.net/pear
downloading Archive_Tar-1.3.3.tgz …
Starting to download Archive_Tar-1.3.3.tgz (18,119 bytes)
……done: 18,119 bytes
downloading Structures_Graph-1.0.3.tgz …
Starting to download Structures_Graph-1.0.3.tgz (30,191 bytes)
…done: 30,191 bytes
downloading PEAR-1.9.0.tgz …
Starting to download PEAR-1.9.0.tgz (291,634 bytes)
…done: 291,634 bytes
upgrade-all ok: channel://pear.php.net/Archive_Tar-1.3.3
upgrade-all ok: channel://pear.php.net/Structures_Graph-1.0.3
upgrade-all ok: channel://pear.php.net/PEAR-1.9.0
PEAR: Optional feature webinstaller available (PEAR’s web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR’s PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR’s PHP-GTK2-based installer)

PEAR: To install optional features use “pear install pear/PEAR#featurename”

好的,如果你到達這一步,恭喜你成功即將離你不遠。

D:\APMServ5.2.6\PHP>pear channel-discover pear.phpunit.de
D:\APMServ5.2.6\PHP>pear install phpunit/PHPUnit

我在執行上面第二句安裝失敗:

Unknown remote channel: pear.symfony-project.com
Did not download optional dependencies: channel://pear.symfony-project.com/YAML,
?use --alldeps to download automatically
phpunit/PHPUnit can optionally use package "channel://pear.symfony-project.com/Y
AML" (version >= 1.0.2)
phpunit/PHPUnit can optionally use PHP extension "soap"
phpunit/PHPUnit requires PHP extension "xdebug" (version >= 2.0.5), installed ve
rsion is 2.0.4
No valid packages found
install failed

?

原因是channel不通,還有xdebug版本過低,於是增加下面代碼

D:\xx\PHP>pear channel-discover pear.symfony-project.com
Adding Channel "pear.symfony-project.com" succeeded
Discovery of channel "pear.symfony-project.com" succeeded

?

D:\xx\PHP>pear channel-discover components.ez.no
Adding Channel "components.ez.no" succeeded
Discovery of channel "components.ez.no" succeeded

再到 http://xdebug.org/download.php?下載最新的 xdebug 仍到 ext 檔案夾中,重啟apache,完成xdebug的升級。

之後在執行安裝phpunit, 成功~

?

?

?

如果這兩個都沒有出錯的話,D:\APMServ5.2.6\PHP目錄下會出現以下四個檔案:

phpunit.bat
phpunit
dbunit.bat
dbunit

好了,檢測安裝是否成功。

校正安裝

D:\APMServ5.2.6\PHP>pear -V

PEAR Version: 1.9.0
PHP Version: 5.2.6
Zend Engine Version: 2.2.0
Running on: Windows NT 5EC44E99C71645F 5.1 build 2600

D:\APMServ5.2.6\PHP>phpunit –version

PHPUnit 3.4.5 by Sebastian Bergmann.

注意如果不成功的話,請使用

d:
cd D:\APMServ5.2.6\PHP
D:\APMServ5.2.6\PHP>phpunit.bat

另外為了避免每次這樣啟動,建議你講D:\APMServ5.2.6\PHP\phpunit.bat 加入環境變數PATH,dbunit亦如此。

?

?

轉載自LixiPHP

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.