If you find this add-on useful, please star it on GitHub — stars show appreciation and help maintainers know their work matters.
Adds phpcs, phpcbf and phpstan commands to wrap web container commands.
ddev add-on get useraccesshub/ddev-php-code-quality
ddev restart
This add-on does not include any specific standards so these will need to be included manually.
ddev composer require --dev drupal/core-dev
OR
ddev composer require --dev drupal/coder
ddev composer require --dev phpstan/phpstan phpstan/extension-installer mglaman/phpstan-drupal phpstan/phpstan-deprecation-rules
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Drupal Project">
<description>Default PHP CodeSniffer configuration for Drupal.</description>
<!-- Check these file extensions -->
<arg name="extensions" value="php,module,inc,install,test,profile,theme"/>
<!-- Use colors in output and show sniff names -->
<arg name="colors"/>
<arg value="s"/>
<!-- Core Drupal standards from the Coder module -->
<rule ref="Drupal"/>
<rule ref="DrupalPractice"/>
<!-- Files or directories to check -->
<file>web/modules/custom</file>
<file>web/themes/custom</file>
<!-- Directories to ignore -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/dist/*</exclude-pattern>
</ruleset>
parameters:
level: 5
excludePaths:
- *node_modules/*
- *vendor/*
- *.twig
fileExtensions:
- php
- module
- inc
- install
- test
- profile
- theme
Run commands
ddev phpcs path/to/file/or/directory
ddev phpcbf path/to/file/or/directory
ddev phpstan analyze path/to/file/or/directory
Show configuration options:
ddev phpcs --config-show
Get installed code standards:
ddev phpcs -i
If you find this add-on useful, please star it on GitHub — stars show appreciation and help maintainers know their work matters.