好的,我正在使用MacBook并为PHP环境安装了MAMP PRO。
我正在尝试使用Pear来安装PHPUnit,但无法使其正常工作。 PHPUnit告诉我pear: command not found
我遇到了一个建议使用sudo php install-pear-nozlib.phar
安装pear的教程,但是当我运行它时,我得到以下内容:
[PEAR] Archive_Tar - already installed: 1.3.7
[PEAR] Console_Getopt - already installed: 1.3.0
[PEAR] Structures_Graph- already installed: 1.0.4
[PEAR] XML_Util - already installed: 1.2.1
[PEAR] PEAR - already installed: 1.9.4
Wrote PEAR system config file at: /Applications/MAMP/bin/php/php5.4.10/conf/pear.conf
You may want to add: /Applications/MAMP/bin/php/php5.4.10/lib/php to your php.ini include_path
好吧,所以它认为Pear已经安装了,但是如果没有找到命令错误,我似乎无法引用它做任何事情。我认为存在某种冲突,因为它已作为MAMP的一部分安装,但是MAMP版本没有通过命令行引用?
我对终端命令知之甚少。我的想法是否在正确的轨道上?
答案 0 :(得分:2)
答案在错误消息中:
您可能需要添加: /Applications/MAMP/bin/php/php5.4.10/lib/php 到你的php.ini include_path
PHP和MAMP的MAMP安装系统范围的PHP。您需要使用PHP的MAMP特定安装。试试这个命令。
sudo /Applications/MAMP/bin/php/php5.4.10/lib/php install-pear-nozlib.phar
另外,以下是我在Mac OS X 10.6.8下安装phpunit
的说明。适用于Mac OS X 10.9。请注意,这是系统安装phpunit
而不是特定于MAMP。
首先获得curl以获得go-pear.phar
:
http://pear.php.net/go-pear.phar > go-pear.phar
此时您可能需要修改.bash_profile
并将/usr/local/pear/bin
添加到$PATH
。
现在运行go-pear.phar
:
sudo php -q go-pear.phar
设置pear
频道:
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
运行命令时可能需要使用pear
明确指出,这样才能正常工作:
sudo /usr/local/pear/bin/pear channel-discover pear.phpunit.de
sudo /usr/local/pear/bin/pear channel-discover components.ez.no
sudo /usr/local/pear/bin/pear channel-discover pear.symfony-project.com
sudo /usr/local/pear/bin/pear channel-discover pear.symfony.com
现在安装phpunit
:
sudo pear install --alldeps phpunit/PHPUnit
现在修改php.ini
:
sudo nano /etc/php.ini
找到includes
路径条目:
;include_path = ".:/php/includes/"
取消注释 - 如果已注释 - 并将其更改为包含pear
路径:
include_path = ".:/usr/local/pear/share/pear:/php/includes/"