PHP-CS-Fixer config for Destination projects
Install the package globally with composer:
composer global require destination/php-cs-fixer-configNow create a .php-cs-fixer.dist.php file within your home directory:
<?php
$config = new Destination\PhpCsFixerConfig\Config();
$config
->setUsingCache(false)
->setRules(array_merge($config->getRules(), [
// Strict types is a sensible default for new projects but is risky on an existing code base
'declare_strict_types' => false,
]))
;
return $config;Assuming your global composer's bin directory is in your $PATH, you can now run the following within a directory you want to format:
php-cs-fixer fix --config ~/.php-cs-fixer.dist.php .
Use composer to add the package to your dev dependencies:
composer require destination/php-cs-fixer-config --devAdd the following to your composer.json:
"scripts": {
"fix": "vendor/bin/php-cs-fixer fix --using-cache=no -v",
}Create a .php-cs-fixer.dist.php file in your project's root directory.
You can copy a typical config file from this package if desired:
$ cp vendor/destination/php-cs-fixer-config/.php-cs-fixer.dist.php .Add the following entries to your .gitignore file:
/.php-cs-fixer.cache
/.php-cs-fixer.php
To fix issues manually, run the following command:
$ composer fixRun the following to have PHP-CS-Fixer run on changed files before every commit:
$ cp vendor/destination/php-cs-fixer-config/git-hooks/pre-commit .git/hooks/pre-commit
$ chmod +x .git/hooks/pre-commitCopy the .editorconfig file from the package into your project so your IDE follows some of our standards:
$ cp vendor/destination/php-cs-fixer-config/.editorconfig .