Files
sept-coding-standard/README.md
2025-07-22 20:11:11 +03:00

66 lines
2.0 KiB
Markdown

# Sept coding standard
We are using [PHP CodeSniffer][1] with the great [Symfony PHP CodeSniffer Coding Standard
of djoos][2] and some sniffs of [Slevomat Coding Standard][3], both adopted to our own needs.
## Goals of our coding standard
* Using already existing standards (PSR-1, PSR-2, Symfony).
* Coding standard can be used across different projects.
* Avoid duplications (also between code, CVS history and documentation).
* Ensure code quality across different dev setups (e.g. different IDEs).
## Installation
If you use [Composer][4], you can install Sept Coding Standard in your project with the following
command:
```BASH
composer require --dev 1sept/sept-coding-standard
```
Optional: To install coding standard automatically edit your composer script:
```JSON
scripts: {
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
],
"auto-scripts": {
"phpcs --config-set installed_paths vendor/1sept/sept-coding-standard": "script",
}
}
```
## Usage
Just create a `phpcs.xml.dist` in your project's root directory with the following content:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="sept-coding-standard">
<rule ref="vendor/1sept/1sept-coding-standard/ruleset.xml">
<!-- If the standard is too hard, you can exclude some rules like this: -->
<!-- <exclude name="Generic.Arrays.DisallowLongArraySyntax.Found" /> -->
<!-- <exclude name="Generic.Files.LineLength.TooLong" /> -->
</rule>
<!-- Exclude project specific files if you want -->
<!-- <exclude-pattern>WakkaFormatter</exclude-pattern> -->
</ruleset>
```
And then you can execute the CodeSniffer like this:
vendor/bin/phpcs -s -p --colors src/
---
[1]: https://github.com/squizlabs/PHP_CodeSniffer#readme
[2]: https://github.com/djoos/Symfony-coding-standard
[3]: https://github.com/slevomat/coding-standard
[4]: https://getcomposer.org/