youwe / coding-standard
Youwe PHP Coding Standard
Installs: 113 787
Dependents: 4
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 6
Open Issues: 1
Type:phpcodesniffer-standard
Requires
- php: ^7.0 || ^8.0
- dealerdirect/phpcodesniffer-composer-installer: ^0.7.2 || ^1.0
- phpmd/phpmd: ^2.0
- squizlabs/php_codesniffer: ^3.9.0
- dev-master
- 3.6.1
- 3.6.0
- 3.5.1
- 3.5.0
- 3.5.0-RC2
- 3.5.0-RC1
- 3.4.0
- 3.4.0-RC1
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.0
- 1.4.1
- 1.4.0
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.0
- dev-array-indent
- dev-namespace-use-statements
This package is auto-updated.
Last update: 2024-12-06 19:19:41 UTC
README
This is the Youwe coding standard, it contains rule sets for PHPCS and PHPMD.
Installation
Use composer to install the coding standard in the home directory.
composer global require youwe/coding-standard
Configuring PHPStorm to use the coding standard.
First configure PHPStorm to use the right phpcs command.
Go to Settings > Languages & Frameworks > PHP > Code Sniffer. Choose
"Local" for the path and fill in the full path to
~/.config/composer/vendor/bin/phpcs
Then go to Settings > Editor > Inspections and search for PHP Code Sniffer
Validation. Select Custom and the add the path to
~/.config/composer/vendor/youwe/coding-standard/src/Youwe
Using the coding standard in a project
To use the standard in a project the standard needs to be required in composer.
cd <project_directory> composer require youwe/coding-standard --dev
This will add the coding standard to the vendor directory of the project.
To let phpcs use the coding standard add a file phpcs.xml to the root of the project.
<?xml version="1.0"?> <ruleset> <rule ref="./vendor/youwe/coding-standard/src/Youwe"/> </ruleset>
The standard can be checked from the command line by going to the directory.
cd <project_directory> ./vendor/bin/phpcs ./src
Configuring PHP CodeSniffer to also show less severe messages
By default PHP CodeSniffer shows only messages with a severity higher than 5. The Youwe coding standard also has some messages with a lower severity. These are messages that encourage a better way of coding but should not block a pull request.
To configure phpcs to show also these messages execute the following command.
~/.config/composer/vendor/bin/phpcs --config-set severity 1