dbt / php-cs-fixer-config
De Boer Tool PHP-CS-Fixer Configuration
Installs: 1 173
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Type:configuration
Requires
This package is auto-updated.
Last update: 2024-12-22 00:24:28 UTC
README
Installation
composer require --dev dbt/php-cs-fixer-config
If you don't already have a .php_cs.dist.php
configuration file, create one in your project root:
touch .php_cs.dist.php
Then fill it out:
<?php use Dbt\PhpCsFixerConfig\Loader; use PhpCsFixer\Finder; $finder = Finder::create()->in([ __DIR__ . '/src', // Add your own directories here. ]); // If you want to add your own rules. If you specify a rule that already exists // in the base ruleset, your local rule will take precedence and override the // base rule. $localRules = require(__DIR __ . '/rules.php'); $loader = Loader::new($finder, $localRules); // If you want to turn off risky tests. $loader->disallowRisky(); return $loader->getConfig();
Composer Scripts
You can optionally add Composer scripts to your composer.json
so you don't have to run PHP-CS-Fixer from your vendor directory each time. For example:
{ "scripts": { "cs": "php-cs-fixer fix", "cs-dry": "php-cs-fixer fix --dry-run" } }
PHPStorm
https://www.jetbrains.com/help/phpstorm/using-php-cs-fixer.html
GrumPHP
If you wish to use GrumPHP to ensure code checks run pre-commit, you can do something like the following:
Install GrumPHP:
composer require --dev phpro/grumphp
Add a configuration file:
touch grumphp.yml
Fill it out, for example:
parameters: ascii: ~ tasks: phpcsfixer2: config: '.php_cs.dist.php'
License
MIT. Do as you wish.