我在 OS X 10.6 上的 MAMP 下运行 phpunit 时遇到问题。我已经通过 PEAR 安装了 phpunit,它存在于 MAMP 目录中,但是当我在终端中运行 phpunit 时没有任何反应。我猜这是一个路径问题,但作为一个 os x 新手,我不知道如何解决它。当我尝试从 /Applications/MAMP/bin/php5.3/bin 运行它时会发生这种情况
$ phpunit
-bash: /usr/bin/phpunit: No such file or directory
$ ./phpunit
$
该问题看起来与如何使用 MAMP 在 Mac 上安装 phpunit 3.5非常相似,但迄今为止的解决方案还没有奏效。以下是更多系统信息:
phpunit 在 MAMP 中的位置
$ sudo find / -name "phpunit"
/Applications/MAMP/bin/php5.3/bin/phpunit
/Applications/MAMP/bin/php5.3/lib/php/PEAR/phing/tasks/ext/phpunit
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
可能是这里的问题
$ which php
/usr/bin/php
$ which phpunit
$ which pear
$ which ./pear
./pear
$ which ./phpunit
./phpunit
我的 php.ini 来自 /Applications/MAMP/conf/php5.3/php.ini
include_path = ".:/Applications/MAMP/bin/php5.3/lib/php:/Applications/MAMP/bin/php5.3/lib/php/PEAR/"
尝试运行或访问 phing 时会发生同样的问题。
再说一次,我猜问题出在路径设置上,但我不知道如何解决这个问题。
谢谢
戴夫
更新
感谢您的答复。我的 pear 是 1.9.2 pear config show lists
$ ./pear config-show
Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels auto_discover <not set>
Default Channel default_channel pear.php.net
HTTP Proxy Server Address http_proxy <not set>
PEAR server [DEPRECATED] master_server pear.php.net
Default Channel Mirror preferred_mirror pear.php.net
Remote Configuration File remote_config <not set>
PEAR executables directory bin_dir /Applications/MAMP/bin/php5.3/bin
PEAR documentation directory doc_dir /Applications/MAMP/bin/php5.3/lib/php/doc
PHP extension directory ext_dir /Applications/MAMP/bin/php5.3/lib/php/extensions
PEAR directory php_dir /Applications/MAMP/bin/php5.3/lib/php/PEAR
PEAR Installer cache directory cache_dir /tmp/pear/cache
PEAR configuration file cfg_dir /Applications/MAMP/bin/php5.3/lib/php/cfg
directory
PEAR data directory data_dir /Applications/MAMP/bin/php5.3/lib/php/data
PEAR Installer download download_dir /tmp/pear/cache
directory
PHP CLI/CGI binary php_bin /Applications/MAMP/bin/php5.3/bin/php
php.ini location php_ini /Applications/MAMP/conf/php5.3/php.ini
--program-prefix passed to php_prefix <not set>
PHP's ./configure
--program-suffix passed to php_suffix <not set>
PHP's ./configure
PEAR Installer temp directory temp_dir /tmp/pear/temp
PEAR test directory test_dir /Applications/MAMP/bin/php5.3/lib/php/test
PEAR www files directory www_dir /Applications/MAMP/bin/php5.3/lib/php/www
Cache TimeToLive cache_ttl 3600
Preferred Package State preferred_state stable
Unix file mask umask 22
Debug Log Level verbose 1
PEAR password (for password <not set>
maintainers)
Signature Handling Program sig_bin /usr/local/bin/gpg
Signature Key Directory sig_keydir /Applications/MAMP/conf/php5.3/pearkeys
Signature Key Id sig_keyid <not set>
Package Signature Type sig_type gpg
PEAR username (for username <not set>
maintainers)
User Configuration File Filename /Users/dave/.pearrc
System Configuration File Filename /Applications/MAMP/conf/php5.3/pear.conf'
/Applications/MAMP/bin/php5.3/bin 的 ls -al 列出 phpunit 等
-rwxr-xr-x 1 dave admin 920 6 Apr 19:55 phing
-r-xr-xr--@ 1 dave admin 57583340 16 Feb 16:08 php
-rwxr-xr-x 1 dave admin 2169 6 Apr 19:48 phpunit
如上所述,php.ini 似乎列出了正确的位置并 echo $PATH 生成
$ echo $PATH
/Applications/MAMP/bin/php5.3/bin:/Applications/MAMP/bin/php5.3/lib/php:/Applications/MAMP/bin/php5.3/lib/php/PEAR/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin