我剛剛在Mac OSX上使用MacPorts安裝了PHP和PEAR,然後使用PEAR安裝了PHPUnit。當我嘗試運行PHPUnit的,我得到了以下錯誤消息:PHPUnit致命錯誤和include_path
$ 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
,所以我試圖
$ 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相當陌生,不想以我不明白的方式對其進行修改。)謝謝。
謝謝你的戰利品! – tasmaniski
你可以這樣做來知道你的php.ini在哪裏:'php --ini' – FerCa
這也適用於我。我必須設置'include_path =「。:/ usr/lib/php/pear /'',因爲這是安裝梨的地方(OSX 10.8.2 Mountain Lion) – Nate