Set of definition and coding standards rules for your SilverStripe project
Via Composer
composer require --dev jdolba/silverstripe-coding-standards ^0.1
- Add scripts to your composer.json file
"scripts": {
"silverstripe-standards": [
"@php-lint",
"@phpcs"
],
"php-lint": "parallel-lint app/src app/tests",
"phpcs": "phpcs app/src app/tests --standard=vendor/jdolba/silverstripe-coding-standards/definitions/php/phpcs-ss4.xml --extensions=php --encoding=utf-8",
"phpcbf": "phpcbf app/src app/tests --standard=vendor/jdolba/silverstripe-coding-standards/definitions/php/phpcs-ss4.xml --extensions=php --encoding=utf-8",
"phpcs-fix": "@phpcbf"
},
- then run:
composer silverstripe-standards
- to fix your Standards violations you can run
composer phpcs-fix
# or
composer phpcbf
you can also customize rules by adding phpcs.xml
file directly to you project root:
cp vendor/jdolba/silverstripe-coding-standards/skeletons/phpcs.xml phpcs.xml
don't forgot to change paths in composer scripts (--standard=phpcs.xml
)
you can use prepared .editorconfig
file (see https://editorconfig.org/)
cp vendor/jdolba/silverstripe-coding-standards/skeletons/.editorconfig .editorconfig
The MIT License (MIT). Please see License File for more information.