PHP Code Checker

Lately I have been looking into Laravel and watching some Laracast videos. In the very first video of the What's New in Laravel 5.1 series, Jeffrey Way talks about how the framework is now adopting PSR-2. In the video he touches on a tool he uses called php-cs-fixer. This tool scans the source code and checks whether or not it is compliant with PSR-2 and even goes as far as updating it for you. Immediately after seeing this I went ahead and added it to my IDE. I was familiar with the concept but never went any further than running linters on my code.

Tools like this allow us to focus on the important stuff and remove the need to have the annoying conversations with other developers about where the curly brackets should go. Another great benefit of using something like this is that all code in your project ends up looking the same, as if there was only one author involved. This can be great compared to having a project where 7 to 8 developers were involved and all had their own style.

If you don't already use a tool like this, consider doing a google search for [ your programming language ] [ your IDE or text editor ] code checker. There is something out there for everyone, not just for PHP. The pros far outweigh the cons when it come to using these types of tools.

If you are on a mac and use PhpStorm, here's how you can set this up. If you have homebrew installed, you can run brew install homebrew/php/php-cs-fixer to get php-cs-fixer on your machine. Once that is done, you can refer to this Gist to get it working within PhpStorm.

I am a big fan of convention over configuration, and any tool that can help keep a team focused on what's important is worth the time it takes to set up. I also think it is more valuable for developers to conform to a set of standards then to have the freedom to format their code in any way that they want. So thank you to all the people who spent days arguing over these sets of standards so I didn't have to.