Windows下安裝PEAR, PHPUnit成功
環(huán)境要求:
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 ‘a(chǎn)ll’ 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, ‘a(chǎn)ll’ 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 ,雙擊,確定,關(guān)閉控制臺窗口,新打開一個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,安裝成功,不過別高興的太早了,還有升級呢…不然無法安裝后續(xù)的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
我在執(zhí)行上面第二句安裝失。
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的升級。
之后在執(zhí)行安裝phpunit, 成功~
如果這兩個都沒有出錯的話,D:\APMServ5.2.6\PHP目錄下會出現(xiàn)以下四個文件:
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 加入環(huán)境變量PATH,dbunit亦如此。
轉(zhuǎn)載自LixiPHP
|