1.1. Upgrade - shinokada/php_notes GitHub Wiki

homebrew php55 or php56

Install php56 with options

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew options php56
brew install --with-cgi php56

Which httpd.conf my apache is using?

Find which http.conf you are using

apachectl -V | grep .conf
// or
/usr/sbin/httpd -V

My OSX Yosemite returns

SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

Add new php5.6. Check /usr/local/Cellar/php56/5.6.*/libexec/apache2/libphp5.so for the new php. My case was 5.6.7

sudo vim /private/etc/apache2/httpd.conf
// comment out LoadModule php5_module and add the following
LoadModule php5_module /usr/local/Cellar/php56/5.6.7/libexec/apache2/libphp5.so

Swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file:

export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

php -v // will give the php version to php 5.6.* or 5.5.* etc.
// now you can use php --ini to return which php.ini is using
php --ini

Adding xdebug

After installing xdebug.

Build process completed successfully
Installing '/usr/local/Cellar/php55/5.5.23/lib/php/extensions/debug-non-zts-20121212/xdebug.so'

Put the followings in php.ini

[xdebug]
zend_extension="/usr/local/Cellar/php55/5.5.23/lib/php/extensions/debug-non-zts-20121212/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir="~/xdebug_profiler_output"
xdebug.idekey=PHPSTORM

Installing extensions

Always reinstall extensions after installing a new PHP. My case is mcrypt and memcached.

Check if all is ok.

php -v
⚠️ **GitHub.com Fallback** ⚠️