Download the PHP package dvsa/coding-standards without Composer
On this page you can find all versions of the php package dvsa/coding-standards. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dvsa/coding-standards
More information about dvsa/coding-standards
Files in dvsa/coding-standards
Package coding-standards
Short Description Coding Standards used for PHP in the Driver and Vehicle Standards Agency. PSR Compliant.
License MIT
Informations about the package coding-standards
DVSA PHP Coding Standards
A custom ruleset for PHP CodeSniffer and PHP-CS-Fixer for use in the Driver and Vehicles Standard Agency (DVSA). PHP Coding standards are maintained and updated by the developer community at the DVSA. See CONTRIBUTING.md for more information how make changes.
Prerequisites
Installation
composer require --dev dvsa/coding-standards
or if you install the coding standard tools globally use:
composer require global dvsa/coding-standards
How to set up
Refer to the How to run section for help with running/integrating in with code editors/IDE.
PHP CodeSniffer
Repository: https://github.com/squizlabs/PHP_CodeSniffer.
- Create a
phpcs.dist.xml
file in the root directory of your project. Example:
PHP-CS-Fixer
Repository: https://github.com/FriendsOfPHP/PHP-CS-Fixer.
Due to the number of dependencies in php-cs-fixer
it must be installed manually.
-
Recommended way to install using composer-bin-plugin.
-
Install
php-cs-fixer
. It is recommended to installPHP-CS-Fixer
in a separate working directory: - Create a
.php-cs-fixer.dist.php
file in the root directory of your project. - Add
.php-cs-fixer.cache
to your.gitignore
. The cache filename can be changed using the$cacheFilename
parameter (default:.php-cs-fixer.cache
). - Configure and return a
PhpCsFixer\ConfigInterface
object. This repository provides a preconfigured class:
Tip: Add .php-cs-fixer.php
to your .gitignore
to enable additional rules locally.
How to run
GitHooks
Recommended using a tool to handle the GitHooks functionality due to the manual steps to set up hooks (symlinks/copying). Lots of tools can be used to handle GitHooks.
Husky & lint-staged (NPM)
Repositories: Husky & lint-staged package.
-
Install using NPM:
-
Configure Husky:
-
Create
.lintstagedrc
: - Add
lint-staged
to thepre-commit
hook:
The above pre-commit hook will utilise both PHP-CS-Fixer and PHPCS. The fixer will be run before PHP CodeSniffer.
Integrations
JetBrains (IntelliJ/PHPStorm)
JetBrains have comprehensive documentation for setting up code quality tools.
PHP CodeSniffer path to ruleset: /phpcs.dist.xml
PHP CS Fixer path to ruleset: /.php-cs-fixer.dist.php
Licence
See LICENSE.md
Contributing
See CONTRIBUTING.md
Acknowledgements
This coding standard is a tweak on top of the PSR2 standard and only possible because of that. However particularly the time and effort of Chris Emerson BJSS is acknowledged for tidying this and working on it during his time on the VOL project.