I recently came across the below phpunit error after upgrading to osx10.8 mountain lion.

PHP Warning:  require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /usr/local/share/pear/PHPUnit/Autoload.php on line 45
PHP Fatal error:  require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:/usr/lib/php/pear') in /usr/local/share/pear/PHPUnit/Autoload.php on line 45

Basically the problem exists because my php.ini include_path was pointed to the wrong place. See below.

To fix it, you need to check the file has been installed, somewhere…

pear list-files phpunit/phpunit

Check for location and replace it with the correct one in the php.ini file (which might be in /private/etc/php.ini symlinked to /etc/php.ini) check by typing php –ini. The steps below are to install from scratch.

  • Download the installer curl http://pear.php.net/go-pear.phar > go-pear.php
  • Start the installation sudo sudo php -q go-pear.php
  • Press 1 and “installation base ($prefix)” and change it to /usr/local
  • Press enter and continue.
  • Create/copy the default php.ini file sudo cp /etc/php.ini.default /etc/php.ini
  • In /etc/php.ini change the include path include_path = ".:/usr/local/share/pear"