To install the code sniffer for PHPStorm:
- Download and install PHP for Windows
- Download https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
- Create a file called phpcs.bat in the C:\php directory
@echo off
"C:\php\php.exe" -f "C:\PATH_TO_DOWNLOADED_PHAR\phpcs.phar" -- %* - In PHPStorm
- Open File->Settings
- Select Languages & Frameworks->PHP
- Add a local interpreter that points to C:\php\php.exe
- Select Languages & Frameworks->PHP->Code Sniffer
- Update the local configuration to point to C:\php\phpcs.bat
- increase the Tool process timeout if you're working on remote code
- Click Validate to ensure that the code sniffer is loaded correctly
- Click Apply
- Select Editor->Inspections
- Select the checkbox for PHP Code Sniffer validation
- Select PHP Code Sniffer validation
- Set the coding standard (you'll probably want PSR2)
- To run the code sniffer
- Press CTRL + ALT + SHIFT + I
- Type "code sniffer" and press enter
- Select the current file
And there you go!
No comments:
Post a Comment