PHPUnit安装到错误的目录


PHPUnit being installed to the wrong directory

我最近按照文档中的指示使用pear包安装程序安装了PHPUnit。Pear当前安装在/usr/local/lib/php/pear中。但是,PHPUnit似乎将自己安装到/usr/share/pear中,因此当我尝试运行phpunit --versionphpunit --help时,我得到了包含错误。

我看到了三个可能的解决方案,但是我害怕如果我选错了,以后会遇到问题。以下是可能的解决方案:(A)将PHPUnit目录从/usr/share/pear/PHPUnit移动到/usr/local/lib/php/pear/PHPUnit, (B)将PHPUnit目录移动到/usr/local/lib/php/pear/share/pear/PHPUnit,或者(C)使用一些额外的命令或开关重新安装PHPUnit,以使其安装到正确的位置?

提前感谢您的帮助。

UPDATE: 以下是pear config-show在我的用户名下运行时的输出:

Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels     auto_discover    1
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          /usr/bin
PEAR documentation directory   doc_dir          /usr/local/lib/php/pear/docs
PHP extension directory        ext_dir          /usr/lib64/php/modules
PEAR directory                 php_dir          /usr/local/lib/php
PEAR Installer cache directory cache_dir        /tmp/pear/cache
PEAR configuration file        cfg_dir          /usr/share/pear/cfg
directory
PEAR data directory            data_dir         /usr/local/lib/php/pear/data
PEAR Installer download        download_dir     /tmp/pear/download
directory
PHP CLI/CGI binary             php_bin          /usr/bin/php
php.ini location               php_ini          <not set>
--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         /usr/local/lib/php/pear/tests
PEAR www files directory       www_dir          /usr/share/pear/www
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  stable
Unix file mask                 umask            27
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          /usr/bin/gpg
Signature Key Directory        sig_keydir       /etc/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         /home/webdeveloper/.pearrc
System Configuration File      Filename         /etc/pear.conf

以下是pear config-show作为root运行时的输出:

Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels     auto_discover    1
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          /usr/bin
PEAR documentation directory   doc_dir          /usr/share/pear/docs
PHP extension directory        ext_dir          /usr/lib64/php/modules
PEAR directory                 php_dir          /usr/share/pear
PEAR Installer cache directory cache_dir        /tmp/pear/cache
PEAR configuration file        cfg_dir          /usr/share/pear/cfg
directory
PEAR data directory            data_dir         /usr/share/pear/data
PEAR Installer download        download_dir     /tmp/pear/download
directory
PHP CLI/CGI binary             php_bin          /usr/bin/php
php.ini location               php_ini          <not set>
--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         /usr/share/pear/tests
PEAR www files directory       www_dir          /usr/share/pear/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/bin/gpg
Signature Key Directory        sig_keydir       /etc/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         /root/.pearrc
System Configuration File      Filename         /etc/pear.conf

好了,看来我们找到问题了(见注释)。

我假设PHPUnit被安装为root或pear,由于某种原因拾取了"root"配置目录。

放置代码的路径定义在:

 PEAR directory  php_dir /usr/share/pear

所以pear配置中的某些东西似乎是问题。

如果可能的话,我将pear config-set php_dir $yourLocation,然后看看是否可行。


It is possible to install multiple versions of PHPUnit 使用pear install --installroot /some/path/,就像在帖子中描述的。所以无论如何都可以。