Warning: require(/usr/lib/php/pear/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43 Fatal error: require(): Failed opening required '/usr/lib/php/pear/PHPUnit/Autoload.php' (include_path='.:') in /usr/bin/phpunit on line 43
想不透原因是什麼,查到了Broken PHP Configuration on OSX Mavericks這篇,試了下底下的command
$sudo pear -V //也可以用pear config-get php_dir
output底下的訊息
Could not open input file: /usr/lib/php/pear/pearcmd.php
看來PEAR真的消失了,參考自己之前寫的PHPUnit學習筆記-PHPUnit安裝(使用PEAR),重新安裝一次
$sudo cp /private/etc/php.ini.default /private/etc/php.ini $sudo php /usr/lib/php/install-pear-nozlib.phar
$sudo pear config-set php_ini /private/etc/php.ini $sudo pear channel-update pear.php.net $sudo pecl channel-update pecl.php.net $sudo pecl config-set php_ini /private/etc/php.ini $sudo pear upgrade-all $sudo vim /private/etc/php.ini
$phpunit -v
重新安裝PHPUnit
$sudo pear config-set auto_discover 1 //sudo pear channel-discover $sudo pear channel-discover pear.phpunit.de $sudo pear channel-discover components.ez.no $sudo pear channel-discover pear.symfony-project.com $sudo pear channel-discover pear.symfony.com $sudo pear install --alldeps phpunit/PHPUnit
再次執行
$phpunit -v
但這次卻一直出現以下的訊息
You have installed PHPUnit via PEAR. This installation method is no longer supported and http://pear.phpunit.de/ will be shut down no later than December, 31 2014. Please read http://phpunit.de/manual/current/en/installation.html and learn how to use PHPUnit from a PHAR or install it via Composer.
執行底下command,看看裝了什麼
$pear list -c pear.phpunit.de
Installed packages, channel pear.phpunit.de: ============================================ Package Version State PHPUnit 4.0.18 stable
看起來很正常,但就是不能用,只好咬牙改用Composer的方式安裝了,找到這篇寫的完整的Installing PHPUnit(官網:Composer、安裝Composer)
先Uninstall
$sudo pear uninstall phpunit/PHPUnit $cd /tmp (先換到tmp目錄) $curl -sS https://getcomposer.org/installer | php
得到以下訊息
#!/usr/bin/env php All settings correct for using Composer Downloading... Composer successfully installed to: /private/tmp/composer.phar Use it: php composer.phar
copy composer.phar去/usr/local/bin
$cp composer.phar /usr/local/bin
$php /usr/local/bin/composer.phar global require "phpunit/phpunit=4.3.*"
安裝完後,到~/.composer/vendor下,要能看到phpunit安裝在這裡
autoload.php composer phpunit symfony bin doctrine sebastian
再來做個link
$cd /usr/bin
$sudo ln -s sudo ln -s /Users/alvin/.composer/vendor/phpunit/phpunit/phpunit phpunit
$phpunit --version
得到底下訊息,可以執行了
PHPUnit 4.3.5 by Sebastian Bergmann.
參考網址:
Broken PHP Configuration on OSX Mavericks
PHPUnit on OSX10.8
Installing PHPUnit
How to remove a package from composer?
composer document
Composer
沒有留言:
張貼留言