Jack Skinner

Ramblings of a programmer

Install PHP7 on OSX with homebrew

5 commands and time for a coffee!

blog

php upgrade

Important This guide is for PHP 7.0; Please see my guide for PHP 7.1 instead.

There's rarely a quiet night in with me, tonight I upgraded my local box to PHP7 (so I don't need to use VM's or docker containers). Took about 10 minutes on my internet connection so there's time to grab a coffee while it downloads!

I used these homebrew instructions from Justin Hileman as the basis for the guide.

If you haven't already, you'll need to have accepted Xcode's license agreement; a simple sudo xcodebuild -license should suffice.

Steps to upgrade

Next up add the taps, unlink the old PHP and add the new!

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew unlink php56
brew install php70

And the result?

$ php --version
PHP 7.0.0 (cli) (built: Dec  2 2015 13:05:57) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

VoilĂ !

Upgrade guide

Upgrading will be different for everyone, but there are three fantastic resources I can recommend to help get started.

First of all, checkout Davey Shafik's Upgrading to PHP7 Guide.

You can also head over to the official migration guide from php.net to review the full changes. After all no one knows your code better than you... right?

Last its time to consider your CI setup. Travis supports 7.0 and whilst it isn't officially in their docs or announced, a quick phpenv check shows they seem to have some PHP7 support already with RC6 available.

Codeship has PHP7RC6 available

Happy coding!