简体   繁体   English

无法运行Phar存档

[英]Cannot run Phar archives

On a RHEL server I cannot seem to run PhpUnit. 在RHEL服务器上,我似乎无法运行PhpUnit。 Here are examples as root to illustrate the steps that I've tried to install PhpUnit and how it does not run: 以下是作为根目录的示例,以说明我尝试安装PhpUnit的步骤以及该步骤如何运行:

# wget https://phar.phpunit.de/phpunit.phar
# chmod +x phpunit.phar
# ./phpunit --version

PHP Fatal error:  require(): Failed opening required 'phar://phpunit-4.3.4.phar/phpunit/TextUI/Command.php' (include_path='.:') in /usr/local/bin/phpunit on line 592
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/phpunit:0
PHP   2. {closure}() /usr/local/bin/phpunit:0

# mv phpunit.phar /usr/local/bin/phpunit
# which phpunit
/usr/local/bin/phpunit

# phpunit --version

PHP Fatal error:  require(): Failed opening required 'phar://phpunit-4.3.4.phar/phpunit/TextUI/Command.php' (include_path='.:') in /usr/local/bin/phpunit on line 592
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/phpunit:0
PHP   2. {closure}() /usr/local/bin/phpunit:0

It seems that PHP is choking on the phar:// address format defined on line 13: 似乎PHP阻塞了第13行定义的phar://地址格式:

# cat /usr/local/bin/phpunit | awk 'NR==592'
          require __PHPUNIT_PHAR_ROOT__ . $classes[$class];

# cat /usr/local/bin/phpunit | grep -n __PHPUNIT_PHAR_ROOT__
13:define('__PHPUNIT_PHAR_ROOT__', 'phar://phpunit-4.3.4.phar');
592:          require __PHPUNIT_PHAR_ROOT__ . $classes[$class];
601:        print file_get_contents(__PHPUNIT_PHAR_ROOT__ . '/manifest.txt');
20811:        if (defined('__PHPUNIT_PHAR_ROOT__')) {
20812:            $prefix = __PHPUNIT_PHAR_ROOT__;
26020:        copy(__PHPUNIT_PHAR_ROOT__ . '/ca.pem', $caFile);

The server is RHEL 6.5: 服务器是RHEL 6.5:

# uname -a
Linux foobar 2.6.32-220.38.1.el6.x86_64 #1 SMP Wed May 15 08:34:56 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

# cat /etc/issue
Red Hat Enterprise Linux Server release 6.5 (Santiago)
Kernel \r on an \m

The solution was to just use PHPUnit from PEAR, which also would not run with this error: 解决的办法是只使用PEAR的PHPUnit,它也不会因以下错误而运行:

[root@panthercrm ~]# /usr/bin/phpunit
PHP Warning:  require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /usr/share/pear/PHPUnit/
Autoload.php on line 64
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. require() /usr/bin/phpunit:43
PHP Fatal error:  require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:') in /usr/share/pear/PHPUni
t/Autoload.php on line 64
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. require() /usr/bin/phpunit:43        

Adding the following line to /etc/php.ini resolved the issue for the PEAR version of PHPUnit: /etc/php.ini添加以下行,可以解决PEAR版本的PHPUnit的问题:

include_path = ".:/usr/share/pear"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM