Reputation: 5092
I'm using GrumPhp to sniff my commit in my symfony project: https://github.com/phpro/grumphp
Here is my config:
parameters:
git_dir: .
bin_dir: vendor/bin
tasks:
phpcsfixer:
config_file: ~
config: sf23
fixers: [psr2, symfony, indentation]
level: psr2
verbose: true
My question is:
Is there a way for Grumphp to automatically run php-cs-fixer
when I commiting?
Upvotes: 5
Views: 4458
Reputation: 1942
GrumPHP always run php-cs-fixer
with the --dry-run
argument and this behavior is not configurable. You can read why here: https://github.com/phpro/grumphp/issues/110
But there's a way to automatically run php-cs-fixer
: you have to install GrumPHP Extra Tasks and replace phpcsfixer2
with php_cs_auto_fixerv2
in your "grumpphp.yml" file.
Be aware that as of today GrumPHP Extra Tasks is not compatible with the latest version of GrumPHP but up to 0.17.2.
Upvotes: 1
Reputation: 666
Yes there is! https://github.com/phpro/grumphp/blob/master/doc/tasks.md
Since your post is a bit older here is the new updated doc, but you can still use version one! https://github.com/phpro/grumphp/blob/master/doc/tasks/php_cs_fixer2.md
You could try out this configuration but it's phpcsfixer version2!:
# grumphp.yml
parameters:
bin_dir: "./vendor/bin"
git_dir: "."
hooks_dir: ~
hooks_preset: local
stop_on_failure: false
ignore_unstaged_changes: false
process_async_limit: 10
process_async_wait: 1000
process_timeout: 60
ascii:
failed: grumphp-grumpy.txt
succeeded: grumphp-happy.txt
tasks:
phpcsfixer2:
allow_risky: false
cache_file: ~
config: ~
rules: ['@Symfony']
using_cache: true
path_mode: ~
verbose: true
Your config looks fine, what's the output ? Do you have the cs fixer installed and configured the grumPHP config to the path of your CS fixer? https://github.com/FriendsOfPHP/PHP-CS-Fixer#usage
Upvotes: 3