Add this repository to composer.json
file:
{
"repositories": [
{
"url": "https://github.com/Fuhrmann/phpcs-fixer-laravel",
"type": "git"
}
]
}
{
"require-dev": {
"fuhrmann/phpcs-fixer-laravel": "master"
}
}
Add the command to the scripts
section:
{
"scripts": {
"fix-style": "vendor/bin/php-cs-fixer fix --config=vendor/fuhrmann/phpcs-fixer-laravel/.php_cs.dist --ansi"
}
}
Then execute the fixer with: composer fix-style
.
Assuming you have a container just for composer.
If you want to fix the styles on every commit, you can:
{
"extra": {
"hooks": {
"pre-commit": [
"docker-compose run --rm composer fix-style"
],
"...": "..."
}
}
}
Declare in the scripts section so the hooks keep updated:
{
"scripts": {
"cghooks": "vendor/bin/cghooks",
"post-install-cmd": "docker-compose run --rm composer cghooks add --ignore-lock",
"post-update-cmd": "docker-compose run --rm composer cghooks update"
}
}
- Check php-cs-fixer official website for rules reference.
- Check composer-git-hooks for the documentation.
Based on this gist with a few changes.