Base PHP CS Fixer configurations for Drupal 7 and 8.

2.1.0 2023-10-23 07:51 UTC

This package is auto-updated.

Last update: 2024-06-15 13:26:21 UTC


Latest Stable Version GitHub stars Total Downloads License Say Thanks! Donate!

PHP CS Fixer Drupal Configurations


This package provides a set [PHP-Cs-Fixer](https://github.com/FriendsOfPHP/PHP CS Fixer) configuration objects ready to be used in a Drupal project.


Available configuration objects:

  • drupol\PhpCsFixerConfigsDrupal\Config\Drupal7
  • drupol\PhpCsFixerConfigsDrupal\Config\Drupal8


  • PHP >= 8.0
  • friendsofphp/php-cs-fixer >= 3.35


The recommended way to install PHP CS Fixer Drupal is to use Composer in a dedicated composer.json file in your project, for example in the tools/php-cs-fixer directory:

mkdir -p tools/php-cs-fixer
composer require --dev --working-dir=tools/php-cs-fixer drupol/phpcsfixer-configs-drupal

Or using the main composer.json:

composer require --dev drupol/phpcsfixer-configs-drupal


Assuming you installed PHP CS Fixer as instructed above, you should now setup a configuration .php-cs-fixer.php file in the root directory of your project.

touch .php-cs-fixer.php

The example below setup PHP CS Fixer to use Drupal 8/9/10 rules:


use drupol\PhpCsFixerConfigsDrupal\Config\Drupal8;

$finder = PhpCsFixer\Finder::create()

$config = new Drupal8();

$rules = $config->getRules();

return $config;

See the PHP CS Fixer documentation on how to use the advanced configuration object.


Assuming you installed PHP CS Fixer as instructed above, you can run the following command to fix your Drupal project:

tools/php-cs-fixer/vendor/bin/php-cs-fixer fix

Code quality, tests and benchmarks

Every time changes are introduced into the library, Github Actions run the tests and the benchmarks.

The library has tests written with PHPUnit. Feel free to check them out in the tests directory. Run ./vendor/bin/phpunit to trigger the tests.

Before each commit some inspections are executed with GrumPHP, run ./vendor/bin/grumphp run to check manually.


Feel free to contribute to this library by sending Github pull requests. I'm quite reactive :-)