LMC Coding Standard for PHP
PHP coding standard used in LMC projects.
Standard is based on PSR-2 and adds various checks to make sure the code is readable, does follow the same conventions and does not contain common mistakes.
We use EasyCodingStandard to define and execute checks created for both PHP-CS-Fixer and PHP_CodeSniffer.
Installation
composer require --dev lmc/coding-standardUsage
- Create
easy-coding-standard.yamlfile in root directory of your project and import the LMC code-style rules:
imports:
- { resource: '%vendor_dir%/lmc/coding-standard/easy-coding-standard.yaml' }- Run the check command (for
src/andtests/directories):
vendor/bin/ecs check src/ tests/- Optionally we recommend adding this to
scriptssection of yourcomposer.json:
"scripts": {
"analyze": [
"vendor/bin/ecs check src/ tests/ --ansi",
"[... other scripts, like PHPStan etc.]"
]
}Exclude (skip) some checks or files
You can configure EasyCodingStandard via parameters section of your easy-coding-standard.yaml to:
- exclude a specific file from all checks (via
exclude_files) - skip specific check from some file(s) or directories (via
skip) - disable whole check (via
exclude_checkers)
Changelog
For latest changes see CHANGELOG.md file. We follow Semantic Versioning.
License
This library is open source software licensed under the MIT license.