PHPUnit致命错误和include_path [英] PHPUnit fatal error and include_path
问题描述
我刚刚使用MacPorts在Mac OSX上安装了PHP和PEAR,然后使用PEAR安装了PHPUnit.当我尝试运行PHPUnit时,出现以下错误消息:
I just installed PHP and PEAR on my Mac OSX using MacPorts and then installed PHPUnit using PEAR. When I try to run PHPUnit, I get the following error message:
$ 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_path
中,所以我尝试了
Okay, so the file File/Iterator/Autoload.php
isn't in my include_path
, so I tried
$ 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还是很陌生,不想以我不理解的方式来处理它.) /p>
It's still not working, and the it's not including the new path that it should be. Does anybody know what I can do about this? (I'd rather not modify my php.ini
file if I can help it because it's read-only and I'm fairly new to PHP and don't want to mangle it in ways I don't understand.) Thanks.
推荐答案
对于命令行上的--include-path
为何不起作用仍然没有答案,所以这就是我所做的:
Still don't have an answer for why --include-path
on the command line isn't working, so here's what I did:
$ which phpunit
/opt/local/bin/phpunit
$ sudo emacs /opt/local/bin/phpunit
计划是修改php.ini
文件,所以首先我必须弄清楚哪个php.ini
正在初始化phpunit
.如果有人有更好的方法可以做到这一点,我很高兴听到它.我在<?php
开头标记之后的phpunit
代码中添加了以下行:
The plan is to modify the php.ini
file, so first I had to figure out which php.ini
was initializing phpunit
. If anyone has a better way to do this, I'm happy to hear it. I added the following line to the phpunit
code right after the <?php
opening tag:
echo php_ini_loaded_file();
现在,当我运行phpunit
时,得到以下输出(此处已被截断):
Now, when I ran phpunit
, I got the following (here truncated) output:
/opt/local/etc/php5/php.iniPHP 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...
然后:
$ sudo emacs /opt/local/etc/php5/php.ini
我搜索了include_path
指令并将:/opt/local/lib/php
附加到末尾.所以现在,phpunit
可以工作了,尽管我不知道我是否会在设置方面破坏其他任何东西.
I searched for the include_path
directive and appended :/opt/local/lib/php
to the end. So now, phpunit
works, although I have no idea if I broke anything else in terms of my setup.
这篇关于PHPUnit致命错误和include_path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!