Brew install php cs fixer
Install command: Show
Also known as: php-cs-fixer@3 Tool to automatically fix PHP coding standards issues https://cs.symfony.com/ License: MIT Formula JSON API: Bottle JSON API:
Formula code: Bottle (binary package) installation support provided. Current versions: Other versions:
Depends on:
Analytics (macOS):
Analytics (Linux):
Install command:
Tool to automatically fix PHP coding standards issues https://cs.symfony.com/ License: MIT Formula JSON API: Bottle JSON API:
Formula code: Bottle (binary package) installation support provided. Current versions: Revision: 1 Keg-only Depends on:
Analytics (macOS):
Analytics (Linux):
To set up php linting, you’ll want to install this PHP CodeSniffer repo and configure with this WordPress Coding Standards repo: . There are a number of ways to do this, whether direct download, Composer, Homebrew, Pear, etc. The
following is what works for me on MacOS using Homebrew: In a terminal window on your Mac, start by updating your Homebrew. Then install the Code Sniffer: After that is done, you should be able to check that things installed correctly. will show you the Standards that you have installed. You will probably see something like:
Once we see the installed standards, we can then download the WordPress Coding Standards. I usually just clone the repo to a directory in the root of my computer, but you can put it anywhere you like, assuming you’ll remember the path.
After that is downloaded, you’ll need to tell phpcs where to find the new coding standards. Assuming you downloaded the repo to the folder above, you can enter:
Otherwise, you will need to point to whereever you intalled your WordPress Coding Standards. Now that you've told phpcs where to find the xml files for WordPress Coding Standards, you can check to see that they are properly found:
and now you should see:
composer global require "squizlabs/php_codesniffer=*"
phpcs --version To lint the php files in a folder
My VSCode Settings{ "phpcs.enable": true, "phpcs.standard": "WordPress", "phpcbf.onsave": true, "phpcbf.standard": "WordPress", "window.zoomLevel": 1, "workbench.colorTheme": "Default Light+", "editor.fontSize": 13, "[javascript]": { "editor.defaultFormatter": "vscode.typescript-language-features" }, "[php]": { "editor.defaultFormatter": "persoderlind.vscode-phpcbf" }, "javascript.updateImportsOnFileMove.enabled": "always", "[javascriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "git.autofetch": true, "editor.insertSpaces": false, "editor.formatOnPaste": true, "editor.tabSize": 4, "editor.detectIndentation": false, "editor.quickSuggestions": true, "[json]": { "editor.defaultFormatter": "vscode.json-language-features" }, "phpcs.executablePath": "/Users/pbarthma/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs", "phpcbf.executablePath": "/Users/pbarthma/.composer/vendor/squizlabs/php_codesniffer/bin/phpcbf", "phpcs.showSources": true, "git.confirmSync": false, "remote.SSH.showLoginTerminal": true, "editor.defaultFormatter": "valeryanm.vscode-phpsab", "editor.codeActionsOnSave": null, "phpsab.standard": "valeryanm.vscode-phpsab", "phpsab.allowedAutoRulesets": [ ".phpcs.xml", ".phpcs.xml.dist", "phpcs.xml", "phpcs.xml.dist", "phpcs.ruleset.xml", "ruleset.xml" ], } My SublimeText 3 PHPCS Settings
SublimeText 3 Preferences Settings
SublimeText 3 Package Control Settings |