Configuring GrumPHP for DDEV

The other day I was running into some issues with GrumPHP. I am working with DDEV for all my projects and I noticed a problem when I wanted to commit something. The composer validation check warned me about a mismatch in the PHP version. Since I am only running composer within the DDEV container, I noticed that the composer validation check was running outside of the container. I run all my Git commands from outside the container so this is not good.

After reading the documentation I found a nice feature in GrumPHP. You can configure the parameters used in the Git hook to execute the commands in grumphp.yml. Here you can tell the git hook to run inside DDEV by adding the following lines on the same level as tasks:

grumphp:
   git_hook_variables:
       EXEC_GRUMPHP_COMMAND: ddev exec php
   tasks:

After you add the changes you need to update the git hook by running:

ddev exec grumphp git:init

if you now run GrumPHP or perform a Git action check will be executed from within DDEV.

Labels