From the inspections screen, expand the PHP | Quality tools node and enable “PHP CodeSniffer validation”. In the Settings dialog, go to Editor > Inspections. You should now see a different error on the Quality Tools page telling you that CodeSniffer inspection is not enabled.Ĭode inspections are how PHPStorm detects (and corrects) problems such as dead code, misspellings, and of course, code style violations in your project. You can click the Validate button to confirm it’s working and click “Apply” when you are done. Specify the full path of the PHPCS executable in the new dialog that opens (which is $YOUR_COMPOSER_BIN_PATH/phpcs). Click the “three dots button” beside the dropdown highlighted below: Expand the PHP Code Sniffer on the Quality Tools page and select Local from the Configuration dropdown. PHPStorm natively supports code inspection with PHP_CodeSniffer, though configuring it is quite some work.įirst, launch the Settings dialog (Ctrl+Alt+S) and navigate to Languages & Frameworks > PHP > Quality Tools. Red lines should appear in all the places with violations as shown below: Note that it also searches your project root for existing rulesets (which is the purpose of the phpcs.xml file in our sample project). Once installed, restart VS Code and the plugin will automatically search your global composer path for a PHPCS installation. Type “ext install phpcs” to find the extension and.Open the Quick Open dialog on VS Code (with Ctrl+P or Cmd+P).Using PHPCS on VS Code is relatively easy as the vscode-phpcs plugin does a lot of heavy-lifting for us. The next time you modify a PHP file and save, PHPCS should run automatically and report any violations that occur in the popup menu. For a complete list of all the possible config options, you can look up the example settings in the plugin source code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |