Code smart with grumphp

Alex Burrows
May 23 · 2 min read

As a developer I like my code to meet coding standards as it makes life easier for everyone. Whenever setting up a codesniffer it can take ages to configure you have to download all the files sometimes it doesn’t work correctly, then rolling it out to others is a real hassle.

Introducing grumphp

Getting grumphp

composer global require phpro/grumphp
composer global update phpro/grumphp

This will allow grumphp to run on your local environment or even a staging server. Then if you are using zshrc simply add:

This will install the grumphp executable in the ~/.composer/vendor/bin folder. Make sure to add this folder to your system $PATH variable:

# .zshrc or .bashrc
export PATH="$HOME/.composer/vendor/bin:$PATH"

Thats it and grumphp is running, it will now sniff your commits and any thing it doesn’t like it WILL tell you in big red text. But hopefully you’ll never find that out.

Drupal conventions

composer require drupol/drupal-conventions --dev

Now if you already are using grumphp like we are then look for grumphp.yml.dist or grumphp.yml

Add this to the top of your yml file

Drupal 8

- { resource: vendor/drupol/drupal-conventions/config/drupal8/grumphp.yml }

Drupal 7

- { resource: vendor/drupol/drupal-conventions/config/drupal7/grumphp.yml }

Now everytime you run a commit grum will tell you and pass / fail you.

If you already have code and you want to check it then by running:

./vendor/bin/grumphp run -v

Will execute everything and run it through:

I will be adding more hints and tips to this post as time goes by.

Alex Burrows

Written by

Drupal Consultant, Technical Director at Digidrop ( and DrupalCamp London organisor -