Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac osx Lion phpunit require(/usr/lib/php/PHPUnit/Autoload.php)

I am migrating to a new computer moving from snow leopard to lion at the same time. phpunit did not seem to make the migration, so I have reinstalled it. However the standard install with pear seems to not work with my home brew install of php. Here is the error:

phpunit
PHP Warning:  require(/usr/lib/php/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43

Warning: require(/usr/lib/php/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43
PHP Fatal error:  require(): Failed opening required '/usr/lib/php/PHPUnit/Autoload.php' (include_path='.:/Users/bimemployee/pear/share/pear:/usr/lib/php') in /usr/bin/phpunit on line 43

Fatal error: require(): Failed opening required '/usr/lib/php/PHPUnit/Autoload.php' (include_path='.:/Users/bimemployee/pear/share/pear:/usr/lib/php') in /usr/bin/phpunit on line 43

I have my computer setup with my main /etc/php.ini file as a symlink to the home brew php.ini file at /usr/local/etc/php.ini this contains my include path which seems to be working.

php -r 'foreach (explode(":", get_include_path()) as $path) echo $path . PHP_EOL;'
No log handling enabled - turning on stderr logging
Cannot find module (LM-SENSORS-MIB): At line 0 in (none)
.
/Users/bimemployee/pear/share/pear
/usr/lib/php

I am also setting up php to work with the homebrew version via the .bash_profile file.

export PATH="$(brew --prefix)/bin:$PATH"
which php
/usr/local/bin/php
which phpunit
/usr/bin/phpunit

Thanks for any help.

-Cory

like image 211
Cory Gwin Avatar asked Sep 19 '26 22:09

Cory Gwin


2 Answers

Maybe you don't have the latest version or the full phpunit installation. You need to install all dependencies using --alldeps So you should install phpunit like this:

pear channel-discover pear.symfony.com # for Yaml dependency
pear channel-discover pear.phpunit.de
pear install --alldeps phpunit/PHPUnit

This work for me ;)

like image 128
MoOx Avatar answered Sep 21 '26 14:09

MoOx


The problem you having might be connected with your include_path, actual (real) php lib directory and with brew link command.

Brew installs php lib into Cellar directory and than links (brew link) all existing resources to /usr/local/lib/php (or /usr/lib/php - depending on your installation).

The problem is File.php and File/ appears in Cellar php lib after linking process (probably after pear update/upgrade). That means it will be not linked in /usr/local/lib/php. To fix it you can simply brew unlink and brew link again.

Additionally it would be good to set your pear php_dir to /usr/local/lib/php. This way all new pear modules will be installed in correct destination without linking process. This makes nice separation between custom Pear modules and PHP lib itself.

like image 34
Tomasz Durka Avatar answered Sep 21 '26 14:09

Tomasz Durka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!