Skip to main content

How to install and configure php-cs-fixer on your C9 workspace and getting nicely formated PHP code for Cloud9 IDE

We and our team at ICF Church love to develop with Cloud9 because of the great sharing and collaborating features. We can create, clone and share our development stack in minutes for others to work on the same project. The need to configure and run a local stack of Apache, MySQL, PHP etc is gone — simply share a url and others are coding happily along…

The missing Feature

One of the things I was missing was automatic code formatting for PHP code — something really useful if your are working with lots of people on the same project. There is an option “Custom Code Formatter” in the PHP settings of the project-preferences, but it was not obvious how it worked and there was nothing to be found on the web.

There is the Setting — But what do we put there?!

Fortunately, my teammate knew a nice formatter and after some probing around, I found a working solution:

The Solution

Download the formatter from Github to your workspace:

$ wget wget -O php-cs-fixer -O ~/php-cs-fixer

Put it into your ~/bin folder:

$ mkdir ~/bin; mv ~/php-cs-fixer ~/bin

Make it executable:

$ chmod a+x ~/bin/php-cs-fixer

Configure your project settings to use the formatter with the desired rules:

php-cs-fixer fix "$file" --rules=@Symfony,@PSR2
Add the above configuration to “Custom Code Formatter” under PHP

Voilà. From now on, every time a file gets saved, it will be automatically checked and formatted according to the defined rule-set. No more different coding-styles across your project.


Als Pionier schrecke ich nicht davor zurück, neue Wege zu gehen und Veränderungen voranzutreiben. Mit meinem technischen Know-how und meiner innovativen Art erkenne ich Chancen und erziele exzellente Ergebnisse. Mit Noevu biete ich Schweizer KMUs Beratung und Entwicklung sowie kontinuierliche Pflege und Verbesserung ihrer Websites im Abonnement, damit ihre digitale Zukunft aufblüht.