Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Last active September 28, 2018 14:13
Show Gist options
  • Save GaryJones/68ac45be594d9860c7de76ce08f6e2ca to your computer and use it in GitHub Desktop.
Save GaryJones/68ac45be594d9860c7de76ce08f6e2ca to your computer and use it in GitHub Desktop.
phpbrew - my config

These are my instructions for compiling a new version of PHP via Phpbrew on Mac High Sierra, with the latest versions of cURL and OpenSSL that Composer seems to need.

Homebrew config

/usr/local/bin must come before /usr/bin in the PATH when using Homebrew.

export PATH=/usr/local/bin:$PATH

Update Homebrew

brew doctor # Fix any bits you can from here
brew update
brew upgrade

Install OpenSSL

brew install openssl

Homebrew now considers openssl to be keg-only, which means it's installed in your machine under /usr/bin/Cellar but isn't symlinked by default.

Take note of the version you have at the end.

Install cURL

This is also keg-only. The --nghttp2 adds HTTP/2 support. See this post.

brew install curl --nghttp2

Take note of the version you have at the end.

Note: For VVV (Ubuntu 16.04), you'll need to sudo apt install libcurl4-openssl-dev in order to install libcurl which ext-curl relies on.

Install gettext

brew install gettext

Take note of the version you have at the end.

Install Bzip2

brew install bzip2

Take note of the version you have at the end.

Update Phpbrew

phpbrew self-update
phpbrew update
phpbrew known

Install PHP with Phpbrew

The custom paths are the ones that contain the respective bin/... directory. Update the OpenSSL and cURL versions as needed, with the versions you have installed.

Note, that the command below excludes gettext, since PHP 7.1.5 and above seems to have an issue with adding iconv extension with gettext extension. Instead, we add iconv as part of the build, and after, add gettext.

phpbrew --debug install 7.2.10 +default +soap +pdo +mysql +openssl=/usr/local/Cellar/openssl/1.0.2p -- --with-iconv=/usr/bin/iconv --with-curl=/usr/local/Cellar/curl/7.61.0 --with-bz2=/usr/local/Cellar/bzip2/1.0.6_1 --with-zlib=/usr/local/opt/zlib
phpbrew ext install gettext -- --with-gettext=/usr/local/Cellar/gettext/0.19.8.1

Note: For VVV (Ubuntu), since apt-get updates the system packages, this would simply be:

phpbrew --debug install 7.2.10 +default +soap +pdo +mysql +openssl

Now wait 5-10 minutes...then after it is finished:

phpbrew switch 7.2.10
phpbrew clean 7.2.10

Remove Old Versions

I'd suggest leaving at least one other earlier version, in case you need to switch away from the very latest for any reason.

phpbrew list
phpbrew remove 7.2.7

Optionally Add in Xdebug

phpbrew ext install xdebug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment