命令phpunit -v给我require_once错误...我的PEAR有什么问题?

时间:2012-09-10 21:10:59

标签: php phpunit pear

根据标题,在新的PHPUnit PEAR安装上运行phpunit -v会导致require_once失败错误。这是一些额外的信息,我希望任何人都可以帮助我。

Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in C:\WAMP\PEAR\pear\PHPUnit\Autoload.php on line 45

Call Stack:
    0.0005     326744   1. {main}() C:\WAMP\PEAR\phpunit:0
    0.0011     369184   2. require('C:\WAMP\PEAR\pear\PHPUnit\Autoload.php') C:\WAMP\PEAR\phpunit:43


Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.;C:\WAMP\PEAR;C:\WAMP\PEAR\pear\PHPUnit') in C:\WAMP\PEAR\pear\PHPUnit\Autoload.php on line 45

Call Stack:
    0.0005     326744   1. {main}() C:\WAMP\PEAR\phpunit:0
    0.0011     369184   2. require('C:\WAMP\PEAR\pear\PHPUnit\Autoload.php') C:\WAMP\PEAR\phpunit:43



    php -v

PHP 5.3.14 (cli) (built: Jun 13 2012 18:51:28) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.0, Copyright (c) 2002-2012, by Derick Rethans

`pear version`:

PEAR Version: 1.9.4
PHP Version: 5.3.14
Zend Engine Version: 2.3.0
Running on: Windows NT MARCO-PC 6.1 build 7601 (Windows 7 Home Premium Edition Service Pack 1) i586

    pear config-get php_dir

C:\WAMP\PEAR\pear

    echo %path% (only relevant paths)
C:\WAMP\PHP;C:\WAMP\PEAR;

    echo %PHP_PEAR_BIN_DIR%
C:\WAMP\PEAR

    echo %PHP_PEAR_DATA_DIR%
C:\WAMP\PEAR\data

    echo %PHP_PEAR_DOC_DIR%
C:\WAMP\PEAR\docs

    echo %PHP_PEAR_INSTALL_DIR%

C:\WAMP\PEAR\pear

    echo %PHP_PEAR_PHP_BIN%

C:\WAMP\PHP\php.exe

    echo %PHP_PEAR_SYSCONF_DIR%

C:\WAMP\PEAR

    echo %PHP_PEAR_TEST_DIR%

C:\WAMP\PEAR\tests

    pear list -c pear.phpunit.de

    INSTALLED PACKAGES, CHANNEL PEAR.PHPUNIT.DE:
    ============================================
    PACKAGE            VERSION STATE
    File_Iterator      1.3.1   stable
    PHPUnit            3.6.12  stable
    PHPUnit_MockObject 1.1.1   stable
    PHP_CodeCoverage   1.1.3   stable
    PHP_Invoker        1.1.0   stable
    PHP_Timer          1.0.2   stable
    PHP_TokenStream    1.1.3   stable
    Text_Template      1.1.1   stable

2 个答案:

答案 0 :(得分:1)

检查依赖关系

如果你最近升级到PHPUnit 3.6,你可能仍然安装了旧版本的File_Iterator,这就是问题(基于相同错误的模糊内存)。

您可以使用以下方法检查已安装软件包的版本:

pear list -c pear.phpunit.de

如果看起来不对,或者只是为了确保升级PHPUnit以确保它是最新版本,那么所有依赖项都是如此:

$ pear update-channels
$ pear upgrade phpunit/PHPUnit
Did not download optional dependencies: phpunit/PHP_Invoker, use --alldeps to download automatically
phpunit/PHPUnit can optionally use package "phpunit/PHP_Invoker" (version >= 1.1.0)
phpunit/PHPUnit_MockObject can optionally use PHP extension "soap"
downloading PHPUnit-3.6.12.tgz ...
Starting to download PHPUnit-3.6.12.tgz (119,220 bytes)
..........................done: 119,220 bytes
downloading File_Iterator-1.3.1.tgz ...
Starting to download File_Iterator-1.3.1.tgz (5,157 bytes)
...done: 5,157 bytes
downloading PHP_CodeCoverage-1.1.3.tgz ...
Starting to download PHP_CodeCoverage-1.1.3.tgz (132,726 bytes)
...done: 132,726 bytes
downloading PHPUnit_MockObject-1.1.1.tgz ...
Starting to download PHPUnit_MockObject-1.1.1.tgz (19,897 bytes)
...done: 19,897 bytes
downloading PHP_TokenStream-1.1.3.tgz ...
Starting to download PHP_TokenStream-1.1.3.tgz (9,860 bytes)
...done: 9,860 bytes
upgrade ok: channel://pear.phpunit.de/File_Iterator-1.3.1
upgrade ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.1.1
upgrade ok: channel://pear.phpunit.de/PHP_TokenStream-1.1.3
upgrade ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.1.3
upgrade ok: channel://pear.phpunit.de/PHPUnit-3.6.12
$ phpunit -v
PHPUnit 3.6.12 by Sebastian Bergmann.

检查包含路径

如果你安装了相应版本的File_Iterator(和其他依赖项),并且File/Iterator/Autoload.php丢失了 - 它没有安装在php正在寻找它的任何地方。使用pear list-files phpunit/File_Iterator查看pear认为该文件的确切位置 - 并验证该文件是否存在。

如果确实如此,梨根不在您的路径中,添加它就可以了。

答案 1 :(得分:0)

运行pear list -c pear.phpunit.de以查看已安装的内容。

你应该看到这样的输出:

Installed packages, channel pear.phpunit.de:
============================================
Package            Version State
File_Iterator      1.3.1   stable
PHPUnit            3.6.11  stable
PHPUnit_MockObject 1.1.1   stable
PHP_CodeCoverage   1.1.2   stable
PHP_Timer          1.0.2   stable
PHP_TokenStream    1.1.3   stable
Text_Template      1.1.1   stable

你可能错过了第一个(至少)。您可以通过并安装每个dependepency,但更简单的方法是pear install -a pear.phpunit.de/PHPUnit-a表示获取所有依赖项,即使已经安装了PHPUnit,它也能正常工作。在上面的系统上运行后,它将PHPUnit升级到3.6.12并且还添加了PHP_Invoker,这似乎是我遗漏了。

Installed packages, channel pear.phpunit.de:
============================================
Package            Version State
File_Iterator      1.3.1   stable
PHPUnit            3.6.12  stable
PHPUnit_MockObject 1.1.1   stable
PHP_CodeCoverage   1.1.3   stable
PHP_Invoker        1.1.0   stable
PHP_Timer          1.0.2   stable
PHP_TokenStream    1.1.3   stable
Text_Template      1.1.1   stable

注意:-a标志也会获得可选的依赖项。如果你是一个可能打扰你的极简主义者: - )