PHP, Coding Standards, and You, Continued
Last time, we learned how to use PHPCodeSniffer and a little command line work to create readable coding standards validation results (that is a mouthful). In this entry, I will document how to integrate PHPCodeSniffer validation into my editor, SciTE.
Prerequisites
- The PHP binary should be located in your system path.
- Windows (for now).
- An understanding that this will probably need some tweaking to work on your system.
Instructions
Download the php source file to your computer, and save it as phpcs-scite.php
Open your SciTE User Options file. This is located in the Options menu, labeled as “Open User Options File”. Paste the following code in there.
command.name.1.*.php=PHP_CodeSniffercommand.1.*.php=php c:/scripts/phpcs-scite.php $(FilePath)- Edit that last line you just pasted to point to the correct location for phpcs-scite.php. Also, you may need to change the “1” in the last two lines to another number if you already have custom commands in the menu.
Now whenever you have a PHP file open in SciTE, you will see an option to run PHP_CodeSniffer in the Tools menu.