Developing software in the Real World

Installing Phan on OS X

I use Homebrew for my local PHP installation on OS X and am currently running PHP 7.0.0 RC8.

Phan is a static analyser for PHP 7 which was written by Rasmus and then rewritten by Andrew Morrison. As it benefits from PHP 7’s abstract syntax tree it can find all kinds of subtle errors, so I wanted to install it locally to have a play with it.

I started by trying to install Phan into my global composer install so that it’s available on my path. As it’s not released on Packagist, I edited ~/.composer/composer.json and added:

to the top, so the I could then install via the standard composer method:

This immediately failed as I don’t have the Nikita’s ast extension installed:

To install this extension:

Now edit you php.ini file (/usr/local/etc/php/7.0/php.ini for Homebrew installations) and add extension=ast.so at the bottom.

Having installed the ast PHP 7 extension, Phan will now install:

Now, Phan works from my command line!

2 thoughts on “Installing Phan on OS X

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *