Menu
Create Custom Side Menus
Frodo's Ghost | Broken PHP Configuration on OSX Mavericks
9
post-template-default,single,single-post,postid-9,single-format-standard,eltd-core-1.0.1,ajax_fade,page_not_loaded,,borderland - frodosghost-child-ver-1.0.0,borderland-ver-1.2, vertical_menu_with_scroll,smooth_scroll,side_menu_slide_with_content,width_470,paspartu_enabled,paspartu_on_bottom_fixed,wpb-js-composer js-comp-ver-4.4.4,vc_responsive

Broken PHP Configuration on OSX Mavericks

For some unfound reason PHPUnit, which was working with my previous OSX install, had broken. I updated to the brand new OSX Mavericks and it killed my setup local development environment, the configuration all reverted. It was showing me the following error:

$ phpunit -c app/
PHP Warning:  require(/usr/lib/php/pear/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/pear/PHPUnit/Autoload.php' (include_path='.:') in /usr/bin/phpunit on line 43

Include Path

When looking at the error that was throw the first problem to correct was the Include Path, which is listed in the php.ini as :: include_path='.:' – there was nothing specified to locate the PHPUnit files for require() function.

Find the location of the PEAR files.

pear config-get php_dir

Error with PEAR

Could not open input file: /usr/lib/php/pear/pearcmd.php

Yes, PEAR was not working. So first thing is to get it up and running again.

sudo /usr/bin/php /usr/lib/php/install-pear-nozlib.phar

Once installed it is suggested from the successful install message we add the PEAR path to the php.ini include path. My installed location was /usr/lib/php/pear.

We shall update PEAR before updating the php.ini.

sudo pear channel-update pear.php.net
sudo pecl channel-update pecl.php.net
sudo pear upgrade --force pear
sudo pear upgrade
sudo pecl upgrade

Set the php.ini file

When I run the command:

php -i | grep Configuration

It shows that there is no configuration file set.

Configuration File (php.ini) Path => /etc
Loaded Configuration File => (none)
Configuration

cd /etc
cp php.ini.default php.ini

Make sure that the date.timezone is set in the php.ini configuration.

Update the ini File

Make sure the correct php.ini file is edited.

php -i | grep Configuration

Configuration File (php.ini) Path => /etc
Loaded Configuration File => /private/etc/php.ini
Configuration

Open the Loaded Configuration File and find the line that specifies the include_path. The base install looks like:

; Original - ;include_path = ".:/php/includes"

Remove the “;” and update the include path:

include_path = ".:/usr/lib/php/pear"

sudo apachectl restart

PHPUnit

Now that PEAR is sorted, running pear version will show the version number, we can move on PHPUnit.

phpunit -v

PHP Warning:  require(/usr/lib/php/pear/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/pear/PHPUnit/Autoload.php' (include_path='.:/usr/lib/php/pear') in /usr/bin/phpunit on line 43

The error is much the same, but our include_path has been updated.

sudo pear config-set auto_discover 1

sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com

sudo pear install phpunit/PHPUnit

phpunit -v
PHPUnit 3.6.12 by Sebastian Bergmann.

Back in business again.

james
3 Comments
  • guest
    Reply

    Thank you for such a helpful post!

    June 25, 2014 at 7:20 pm
  • guest
    Reply

    i love you

    September 23, 2014 at 10:30 pm
    • james@frodosghost.com
      Reply

      Thanks… Just trying to help out.

      September 24, 2014 at 12:35 am

Post a Reply to guest Cancel Reply