composer require --dev fpcs/php-coding-standard
<?xml version="1.0"?>
<ruleset>
<rule ref="vendor/fpcs/php-coding-standard/phpcs" />
</ruleset>
imports:
- { resource: 'vendor/symplify/easy-coding-standard/config/set/psr2.yaml' }
- { resource: 'vendor/symplify/easy-coding-standard/config/set/clean-code.yaml' }
- { resource: 'vendor/fpcs/php-coding-standard/easy-coding-standard/*.yaml' }
There are base
standards, and then more specific standards, which should be used IN ADDITION to the base
standard.
Available standards:
base
(always use)laravel
<?xml version="1.0"?>
<ruleset>
<rule ref="vendor/fpcs/php-coding-standard/phpcs/base.xml" />
<rule ref="vendor/fpcs/php-coding-standard/phpcs/laravel.xml" />
</ruleset>
imports:
- { resource: 'vendor/symplify/easy-coding-standard/config/set/psr2.yaml' }
- { resource: 'vendor/symplify/easy-coding-standard/config/set/clean-code.yaml' }
- { resource: 'vendor/fpcs/php-coding-standard/easy-coding-standard/base.yaml' }
- { resource: 'vendor/fpcs/php-coding-standard/easy-coding-standard/laravel.yaml' }
"scripts": {
...
"ecs": "./vendor/bin/ecs check ./ --fix",
"phpcbf": "./vendor/bin/phpcbf ./",
"phpcs": "./vendor/bin/phpcs -sp ./",
"lint": "yarn ecs && yarn phpcbf",
...
},
module.exports = {
'*.php': files => [
`./vendor/bin/ecs check --fix "${files.join('" "')}"`,
`./vendor/bin/phpcbf "${files.join('" "')}"`,
`git add "${files.join('" "')}"`,
],
};
yarn lint