PHPackages                             dvsa/coding-standards - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. dvsa/coding-standards

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

dvsa/coding-standards
=====================

Coding Standards used for PHP in the Driver and Vehicle Standards Agency. PSR Compliant.

v2.0.0(4y ago)053.6k—4.7%2[2 PRs](https://github.com/dvsa/php-coding-standards/pulls)8MITPHPPHP ^7.4|^8.0

Since Jun 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dvsa/php-coding-standards)[ Packagist](https://packagist.org/packages/dvsa/coding-standards)[ RSS](/packages/dvsa-coding-standards/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (4)Used By (8)

DVSA PHP Coding Standards
=========================

[](#dvsa-php-coding-standards)

A custom ruleset for [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) and [PHP-CS-Fixer](https://github.com/FriendsOfPHP/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](/CONTRIBUTING.md) for more information how make changes.

Prerequisites
-------------

[](#prerequisites)

- [Composer](https://getcomposer.org/)
- *at least* PHP 7.4
- [Git](https://git-scm.com/)

Installation
------------

[](#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
-------------

[](#how-to-set-up)

Refer to the [Integrations](#integrations) or [How to run](#how-to-run) section for help with running/integrating in with code editors/IDE.

### PHP CodeSniffer

[](#php-codesniffer)

Repository: [https://github.com/squizlabs/PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).

1. Create a `phpcs.dist.xml` file in the root directory of your project. Example: ```

      ./path/to/directory
      ./path/to/file.php

      */vendor/*

    ```

[XML reference](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset).

### PHP-CS-Fixer

[](#php-cs-fixer)

Repository: .

Due to the number of dependencies in `php-cs-fixer` it must be installed manually.

1. Recommended way to install using [composer-bin-plugin](https://github.com/bamarni/composer-bin-plugin). ```
    $ composer require --dev bamarni/composer-bin-plugin
    ```
2. Install `php-cs-fixer`. It is [recommended](https://github.com/FriendsOfPHP/PHP-CS-Fixer#installation) to install `PHP-CS-Fixer` in a separate working directory: ```
    $ composer bin php-cs-fixer require friendsofphp/php-cs-fixer dvsa/coding-standards
    ```
3. Create a `.php-cs-fixer.dist.php` file in the root directory of your project.
4. Add `.php-cs-fixer.cache` to your `.gitignore`. The cache filename can be changed using the `$cacheFilename` parameter (default: `.php-cs-fixer.cache`).
5. Configure and return a `PhpCsFixer\ConfigInterface` object. This repository provides a preconfigured class: ```
