ddev ssh
composer require drupal/coder --dev
composer require dealerdirect/phpcodesniffer-composer-installer --dev
composer require loomgmbh/git-hooks-pre-commit-ddev --dev
# .ddev/setup.local.sh
hook_post_setup() {
+ echo "Add custom PHPCS config."
+ phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer;
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md web/modules/custom
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md web/themes/custom
# With automatic fix
phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md web/modules/custom
When installed, the phpcbf will run on every commit and attempt to make corrections. Corrections made by phpcbf must then be seperately committed.
# .ddev/setup.local.sh
hook_post_setup() {
echo "Add custom PHPCS config."
phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer;
+ echo "Setup pre-commit-ddev.";
+ cp "vendor/loomgmbh/git-hooks-pre-commit-ddev/pre-commit-ddev" ".git/hooks/pre-commit";
+ chmod +x ".git/hooks/pre-commit";