PHPCS Configuration
FrameBase has PHP Codesniffer (PHPCS) included within the package, a tool that validates your code against a set of predefined standards and ensures that such standards are maintained across the team.
To utilize it's potential to the fullest, make sure to install any PHPCS Linter plugin in VS Code.
PHPCS Plugin Installation
- Open Visual Studio Code.
- Press
Ctrl+P
on Windows (orCmd+P
on Mac) to open the Quick Open dialog. - Type
ext install phpcs
to find an extension. - Click on the
Install
Button or click the cloud icon to install it. - Restart Visual Studio Code if needed (when prompted)
There are multiple phpcs
plugins available in the VS Code Marketplace, but some of them are deprecated or no longer maintained. We recommend to use the plugin phpcs v1.0.8
from the author shevaua
PHP CodeSniffer Configuration
PHP Codesniffer is configured for VS Code by default in FrameBase. You might not need to re-configure, if you open VS Code within the Project Folder.
-
Open Visual Studio Code inside your Project Folder
-
Navigate to
Settings
usingCtrl+,
(orCMD+,
in Mac)- You may also navigate through the menu
File > Prefernces > Settings
- You may also navigate through the menu
-
Click on
Workspace
from the Menu Tab located below the Search -
Type
phpcs
in the Search Bar -
Click on
PHP CodeSniffer Configuration
-
Locate the setting, Phpcs: Composer JSON Path and fill the value:
docker/library/composer.json
-
Locate the setting, Phpcs: Executable Path and fill the value:
docker/library/vendor/squizlabs/php_codesniffer/bin/phpcs
Why PHP CodeSniffer?
While you commit & push your changes to the repository, the CI/CD Pipeline will run a Build Test to verify the Coding Standards are met & satisfied by the changes you've made.
The same set of Coding Standards are predefined in the PHP CodeSniffer and you will be notified about any incompatibility in the changes you made.
This approach will help you save time & effort you've to spend for fixing compatibility issues. It might also help you improve your coding abilities.