Install PHPCS at the project level
Installing PHPCS at the project level limits the availability of PHPCS to only from within that project directory. Following these instructions will install:
- The latest compatible version of PHPCS
- The latest release of VIP-Coding-Standards (VIPCS)
- A compatible version of the WordPress Coding Standards (WordPressCS)
- Compatible versions of other standards packages, like VariableAnalysis, PHPCSUtils and PHPCSExtra
Note
PHPCS commands on a local machine running Windows may require different formatting than the command examples shown below.
Install
In the local machine’s terminal:
- Before beginning installation, ensure that Composer itself is up to date:
composer self-update && composer global update
- Navigate (
cd
) to the root of the project. - Run the following command to add or update
composer.json
andcomposer.lock
files and avendor/
directory (thevendor/
directory can optionally be ignored in version control):
composer require --dev automattic/vipwpcs
Command formatting
When PHPCS is installed locally (at the project level), it will be necessary to format the commands shown below directly referencing the executable at vendor/bin/phpcs
instead of phpcs
.
For example, this command:
phpcs -i
should instead be formatted as:
vendor/bin/phpcs -i
Last updated: December 23, 2023