PHPUnit致命错误和include_路径
我只是使用MacPorts在MacOSX上安装了PHP和PEAR,然后使用PEAR安装了PHPUnit。当我尝试运行PHPUnit时,会收到以下错误消息:PHPUnit致命错误和include_路径,php,phpunit,Php,Phpunit,我只是使用MacPorts在MacOSX上安装了PHP和PEAR,然后使用PEAR安装了PHPUnit。当我尝试运行PHPUnit时,会收到以下错误消息: $ phpunit StackTest.php PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php
$ phpunit StackTest.php
PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
PHP Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:/php/includes:/usr/local/php5/lib/php:/opt/local/lib/php/pear') in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:/php/includes:/usr/local/php5/lib/php:/opt/local/lib/php/pear') in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
好的,所以文件file/Iterator/Autoload.php
不在我的include\u路径中,所以我尝试了
$ ls -l /opt/local/lib/php/File/Iterator/Autoload.php
-rw-r--r-- 1 root admin 2682 May 23 14:38 /opt/local/lib/php/File/Iterator/Autoload.php
$ phpunit --include-path /opt/local/lib/php StackTest.php
PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
PHP Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:/php/includes:/usr/local/php5/lib/php:/opt/local/lib/php/pear') in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:/php/includes:/usr/local/php5/lib/php:/opt/local/lib/php/pear') in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
它仍然不起作用,而且它没有包括它应该是的新路径。有人知道我能做什么吗?(如果我能帮助的话,我不想修改我的php.ini
文件,因为它是只读的,而且我对php还相当陌生,不想以我不理解的方式弄乱它。)谢谢。我在Windows安装中遇到了类似的问题,但我不确定在OSX上是否也是同样的问题。我发现PEAR安装在用于启动程序的批处理文件中创建了错误的路径
标准安装会导致安装的批处理文件出错。pear.bat批处理文件的最后一行脚本需要将include_路径用单引号括起来(“include_路径=“%VARIABLE%”)
我所做的改变是:
"%PHP_PEAR_PHP_BIN%" -C -d memory_limit="-1" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" -d variables_order=EGPCS -d open_basedir="" -d output_buffering=1 -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
我不确定您的安装是否存在与上述问题类似的问题
如果失败,我在Windows7上的PHPUnit批处理文件是
if "%PHPBIN%" == "" set PHPBIN=C:\Program Files (x86)\PHP\php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "C:\Program Files (x86)\PHP\phpunit" %*
我在安装Windows时遇到了类似的问题,但我不确定在OSX上是否也是同样的问题。我发现PEAR安装在用于启动程序的批处理文件中创建了错误的路径
标准安装会导致安装的批处理文件出错。pear.bat批处理文件的最后一行脚本需要将include_路径用单引号括起来(“include_路径=“%VARIABLE%”)
我所做的改变是:
"%PHP_PEAR_PHP_BIN%" -C -d memory_limit="-1" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" -d variables_order=EGPCS -d open_basedir="" -d output_buffering=1 -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
我不确定您的安装是否存在与上述问题类似的问题
如果失败,我在Windows7上的PHPUnit批处理文件是
if "%PHPBIN%" == "" set PHPBIN=C:\Program Files (x86)\PHP\php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "C:\Program Files (x86)\PHP\phpunit" %*
对于命令行上的--include path
不起作用的原因,仍然没有答案,所以我做了如下操作:
$ which phpunit
/opt/local/bin/phpunit
$ sudo emacs /opt/local/bin/phpunit
计划是修改php.ini
文件,因此首先我必须确定哪个php.ini
正在初始化phpunit
。如果有人有更好的方法,我很高兴听到。我在之后的phpunit
代码中添加了以下行,但仍然无法解释为什么命令行上的--include path
不起作用,因此我做了如下操作:
$ which phpunit
/opt/local/bin/phpunit
$ sudo emacs /opt/local/bin/phpunit
计划是修改php.ini
文件,因此首先我必须确定哪个php.ini
正在初始化phpunit
。如果有人有更好的方法,我很高兴听到。我在之后的phpunit
代码中添加了以下一行,一种侵入性较小的方法(不永久更改php.ini)是在失败的脚本中包含以下一行:set_include_path(“/opt/local/lib/php/”代码>
您包含的位置可能略有不同。如果这不起作用,请搜索一个名为Autoload.php的文件,该文件位于如下文件夹结构中:file/Iterator/Autoload.php,并使用文件路径作为set\u include\u path()
中的路径,这是一种侵入性较小的方式(无需永久更改php.ini)将在失败的脚本中包含以下行:set_include_path(“/opt/local/lib/php/”)代码>
您包含的位置可能略有不同。如果这不起作用,搜索一个名为Autoload.php的文件,该文件位于如下文件夹结构中:file/Iterator/Autoload.php,并使用文件路径作为set\u include\u path()
中的路径。您可以这样做,以知道您的php.ini在哪里:php--ini
这对我也很有用。我必须设置include_path=“.:/usr/lib/php/pear/”
,因为pear就是在那里安装的(OSX 10.8.2 Mountain Lion),你可以这样做来知道你的php.ini在哪里:php--ini
这对我也很有用。我必须设置include_path=“.:/usr/lib/php/pear/”
,因为pear就是在那里安装的(OSX 10.8.2 Mountain Lion)