PHP-CS-Fixer is yet another extremely handy utility to emerge from Sensiolabs to help manage code style compliance.

I use it as part of my git workflow (see my magento githooks repo) and I find it really does help keep code consistent.

When you work on projects with more than a couple of developers, niggling differences in style can lead to unintentional errors creeping into your codebase (think omitting braces in if statements, for example).

Anyway, one of the neat features in the master branch is the ability to specify a config file to control how php-cs-fixer behaves rather than having to define everything on the commandline (or depend on .php_cs being in the path). Unfortunately this feature is not yet in a pre-baked release of php-cs-fixer. So to use it you have to use the source version. I quite like the convenience of the phar version but it's unclear how to build one directly from the sources.

After a bit of digging around in the code and issues list, I found they are using the php-box project to build release phars. It's actually very simple, but to save others having to figure it all out, just follow these steps.

$ git clone https://github.com/fabpot/PHP-CS-Fixer
$ cd PHP-CS-Fixer
$ composer.phar require --dev 'kherge/box=~2.4'
$ vendor/kherge/box/bin/box build
> Building...

Do a quick _ls_ and you'll notice you have a minty fresh php-cs-fixer.phar file.

Done.