{"id":20180574,"url":"https://github.com/ergebnis/php-cs-fixer-config","last_synced_at":"2026-04-12T13:10:21.233Z","repository":{"id":38865400,"uuid":"224016660","full_name":"ergebnis/php-cs-fixer-config","owner":"ergebnis","description":"📓 Provides a composer package with a configuration factory and rule set factories for friendsofphp/php-cs-fixer.","archived":false,"fork":false,"pushed_at":"2025-05-12T19:45:52.000Z","size":6498,"stargazers_count":71,"open_issues_count":2,"forks_count":15,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T20:48:10.631Z","etag":null,"topics":["configuration","php-cs-fixer"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ergebnis.png","metadata":{"funding":{"github":["ergebnis","localheinz"]},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-25T18:38:21.000Z","updated_at":"2025-05-12T19:45:56.000Z","dependencies_parsed_at":"2023-09-26T16:11:16.845Z","dependency_job_id":"d9c91ce9-054e-4bdb-8d02-8ac059240e96","html_url":"https://github.com/ergebnis/php-cs-fixer-config","commit_stats":{"total_commits":913,"total_committers":10,"mean_commits":91.3,"dds":0.5049288061336255,"last_synced_commit":"1b939dd8ed3ec1dd8a20d531f63a9930a357f5cc"},"previous_names":[],"tags_count":141,"template":false,"template_full_name":"ergebnis/php-cs-fixer-config-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphp-cs-fixer-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphp-cs-fixer-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphp-cs-fixer-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphp-cs-fixer-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ergebnis","download_url":"https://codeload.github.com/ergebnis/php-cs-fixer-config/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493378,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","php-cs-fixer"],"created_at":"2024-11-14T02:31:44.981Z","updated_at":"2026-04-12T13:10:21.219Z","avatar_url":"https://github.com/ergebnis.png","language":"PHP","funding_links":["https://github.com/sponsors/ergebnis","https://github.com/sponsors/localheinz"],"categories":[],"sub_categories":[],"readme":"# php-cs-fixer-config\n\n[![Integrate](https://github.com/ergebnis/php-cs-fixer-config/actions/workflows/integrate.yaml/badge.svg?branch=main)](https://github.com/ergebnis/php-cs-fixer-config/actions/workflows/integrate.yaml)\n[![Merge](https://github.com/ergebnis/php-cs-fixer-config/actions/workflows/merge.yaml/badge.svg)](https://github.com/ergebnis/php-cs-fixer-config/actions/workflows/merge.yaml)\n[![Release](https://github.com/ergebnis/php-cs-fixer-config/actions/workflows/release.yaml/badge.svg)](https://github.com/ergebnis/php-cs-fixer-config/actions/workflows/release.yaml)\n[![Renew](https://github.com/ergebnis/php-cs-fixer-config/actions/workflows/renew.yaml/badge.svg)](https://github.com/ergebnis/php-cs-fixer-config/actions/workflows/renew.yaml)\n\n[![Code Coverage](https://codecov.io/gh/ergebnis/php-cs-fixer-config/branch/main/graph/badge.svg)](https://codecov.io/gh/ergebnis/php-cs-fixer-config)\n\n[![Latest Stable Version](https://poser.pugx.org/ergebnis/php-cs-fixer-config/v/stable)](https://packagist.org/packages/ergebnis/php-cs-fixer-config)\n[![Total Downloads](https://poser.pugx.org/ergebnis/php-cs-fixer-config/downloads)](https://packagist.org/packages/ergebnis/php-cs-fixer-config)\n[![Monthly Downloads](http://poser.pugx.org/ergebnis/php-cs-fixer-config/d/monthly)](https://packagist.org/packages/ergebnis/php-cs-fixer-config)\n\nThis project provides a [`composer`](https://getcomposer.org) package with a configuration factory and rule set factories for [`friendsofphp/php-cs-fixer`](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer).\n\n## Installation\n\nRun\n\n```sh\ncomposer require --dev ergebnis/php-cs-fixer-config\n```\n\n## Usage\n\n### Configuration\n\nPick one of the rule sets:\n\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php53`](src/RuleSet/Php53.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php54`](src/RuleSet/Php54.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php55`](src/RuleSet/Php55.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php56`](src/RuleSet/Php56.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php70`](src/RuleSet/Php70.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php71`](src/RuleSet/Php71.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php72`](src/RuleSet/Php72.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php73`](src/RuleSet/Php73.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php74`](src/RuleSet/Php74.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php80`](src/RuleSet/Php80.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php81`](src/RuleSet/Php81.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php82`](src/RuleSet/Php82.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php83`](src/RuleSet/Php83.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php84`](src/RuleSet/Php84.php)\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Php85`](src/RuleSet/Php85.php)\n\nCreate a configuration file `.php-cs-fixer.php` in the root of your project:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Ergebnis\\PhpCsFixer\\Config;\nuse PhpCsFixer\\Finder;\n\n$ruleSet = Config\\RuleSet\\Php83::create();\n\n$finder = Finder::create()-\u003ein(__DIR__);\n\n$config = Config\\Factory::fromRuleSet($ruleSet);\n\n$config-\u003esetCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');\n$config-\u003esetFinder($finder);\n\nreturn $config;\n```\n\n### Git\n\nAll configuration examples use the caching feature, and if you want to use it as well, you should add the cache directory to `.gitignore`:\n\n```diff\n+ /.build/\n /vendor/\n```\n\n### Configuring a rule set with header\n\n:bulb: Optionally specify a header:\n\n```diff\n \u003c?php\n\n declare(strict_types=1);\n\n use Ergebnis\\PhpCsFixer\\Config;\n use PhpCsFixer\\Finder;\n\n+$header = \u003c\u003c\u003cEOF\n+Copyright (c) 2023 Andreas Möller\n+\n+For the full copyright and license information, please view\n+the LICENSE file that was distributed with this source code.\n+\n+@see https://github.com/ergebnis/php-cs-fixer-config\n+EOF;\n\n-$ruleSet = Config\\RuleSet\\Php83::create();\n+$ruleSet = Config\\RuleSet\\Php83::create()-\u003ewithHeader($header);\n\n $finder = Finder::create()-\u003ein(__DIR__);\n\n $config = Config\\Factory::fromRuleSet($ruleSet);\n\n $config-\u003esetCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');\n $config-\u003esetFinder($finder);\n\n return $config;\n```\n\nThis will enable and configure the [`HeaderCommentFixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.1.1/src/Fixer/Comment/HeaderCommentFixer.php), so that file headers will be added to PHP files, for example:\n\n```diff\n \u003c?php\n\n declare(strict_types=1);\n\n+/**\n+ * Copyright (c) 2023 Andreas Möller\n+ *\n+ * For the full copyright and license information, please view\n+ * the LICENSE file that was distributed with this source code.\n+ *\n+ * @see https://github.com/ergebnis/php-cs-fixer-config\n+ */\n```\n\n### Configuring a rule set that overrides rules\n\n:bulb: Optionally override rules from a rule set by passing a set of rules to be merged in:\n\n```diff\n \u003c?php\n\n declare(strict_types=1);\n\n use Ergebnis\\PhpCsFixer\\Config;\n use PhpCsFixer\\Finder;\n\n-$ruleSet = Config\\RuleSet\\Php83::create();\n+$ruleSet = Config\\RuleSet\\Php83::create()-\u003ewithRules(Config\\Rules::fromArray([\n+    'mb_str_functions' =\u003e false,\n+    'strict_comparison' =\u003e false,\n+]));\n\n $finder = Finder::create()-\u003ein(__DIR__);\n\n $config = Config\\Factory::fromRuleSet($ruleSet);\n\n $config-\u003esetCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');\n $config-\u003esetFinder($finder);\n\n return $config;\n```\n\n### Configuring a rule set that registers and configures rules for custom fixers\n\n:bulb: Optionally register and configure rules for custom fixers:\n\n```diff\n \u003c?php\n\n declare(strict_types=1);\n\n use Ergebnis\\PhpCsFixer\\Config;\n use FooBar\\Fixer;\n use PhpCsFixer\\Finder;\n\n-$ruleSet = Config\\RuleSet\\Php83::create();\n+$ruleSet = Config\\RuleSet\\Php83::create()\n+    -\u003ewithCustomFixers(Config\\Fixers::fromFixers(\n+        new Fixer\\BarBazFixer(),\n+        new Fixer\\QuzFixer(),\n+    ))\n+    -\u003ewithRules(Config\\Rules::fromArray([\n+        'FooBar/bar_baz' =\u003e true,\n+        'FooBar/quz' =\u003e [\n+            'qux =\u003e false,\n+        ],\n+    ]))\n+]);\n\n $finder = Finder::create()-\u003ein(__DIR__);\n\n $config = Config\\Factory::fromRuleSet($ruleSet);\n\n $config-\u003esetCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');\n $config-\u003esetFinder($finder);\n\n return $config;\n```\n\n### Makefile\n\nIf you like [`Makefile`](https://www.gnu.org/software/make/manual/make.html#Introduction)s, create a `Makefile` with a `coding-standards` target:\n\n```diff\n+.PHONY: coding-standards\n+coding-standards: vendor\n+    mkdir -p .build/php-cs-fixer\n+    vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --show-progress=dots --verbose\n\n vendor: composer.json composer.lock\n     composer validate\n     composer install\n```\n\nRun\n\n```sh\nmake coding-standards\n```\n\nto automatically fix coding standard violations.\n\n### Composer script\n\nIf you like [`composer` scripts](https://getcomposer.org/doc/articles/scripts.md), add a `coding-standards` script to `composer.json`:\n\n```diff\n {\n   \"name\": \"foo/bar\",\n   \"require\": {\n     \"php\": \"^8.1\",\n   },\n   \"require-dev\": {\n     \"ergebnis/php-cs-fixer-config\": \"^6.21.0\"\n+  },\n+  \"scripts\": {\n+    \"coding-standards\": [\n+      \"mkdir -p .build/php-cs-fixer\",\n+      \"php-cs-fixer fix --diff --show-progress=dots --verbose\"\n+    ]\n   }\n }\n```\n\nRun\n\n```sh\ncomposer coding-standards\n```\n\nto automatically fix coding standard violations.\n\n### GitHub Actions\n\nIf you like [GitHub Actions](https://github.com/features/actions), add a `coding-standards` job to your workflow:\n\n```diff\n on:\n   pull_request: null\n   push:\n     branches:\n       - main\n\n name: \"Integrate\"\n\n jobs:\n+  coding-standards:\n+    name: \"Coding Standards\"\n+\n+    runs-on: ubuntu-latest\n+\n+    strategy:\n+      matrix:\n+        php-version:\n+          - \"8.1\"\n+\n+    steps:\n+      - name: \"Checkout\"\n+        uses: \"actions/checkout@v2\"\n+\n+      - name: \"Set up PHP\"\n+        uses: \"shivammathur/setup-php@v2\"\n+        with:\n+          coverage: \"none\"\n+          php-version: \"${{ matrix.php-version }}\"\n+\n+      - name: \"Cache dependencies installed with composer\"\n+        uses: \"actions/cache@v2\"\n+        with:\n+          path: \"~/.composer/cache\"\n+          key: \"php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}\"\n+          restore-keys: \"php-${{ matrix.php-version }}-composer-\"\n+\n+      - name: \"Install locked dependencies with composer\"\n+        run: \"composer install --ansi --no-interaction --no-progress --no-suggest\"\n+\n+      - name: \"Create cache directory for friendsofphp/php-cs-fixer\"\n+        run: mkdir -p .build/php-cs-fixer\n+\n+      - name: \"Cache cache directory for friendsofphp/php-cs-fixer\"\n+        uses: \"actions/cache@v2\"\n+        with:\n+          path: \"~/.build/php-cs-fixer\"\n+          key: \"php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }}\"\n+          restore-keys: |\n+            php-${{ matrix.php-version }}-php-cs-fixer-main\n+            php-${{ matrix.php-version }}-php-cs-fixer-\n+\n+      - name: \"Run friendsofphp/php-cs-fixer\"\n+        run: \"vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --dry-run --show-progress=dots --verbose\"\n```\n\n## Changelog\n\nThe maintainers of this project record notable changes to this project in a [changelog](CHANGELOG.md).\n\n## Contributing\n\nThe maintainers of this project suggest following the [contribution guide](.github/CONTRIBUTING.md).\n\n## Code of Conduct\n\nThe maintainers of this project ask contributors to follow the [code of conduct](https://github.com/ergebnis/.github/blob/main/CODE_OF_CONDUCT.md).\n\n## General Support Policy\n\nThe maintainers of this project provide limited support.\n\nYou can support the maintenance of this project by [sponsoring @ergebnis](https://github.com/sponsors/ergebnis).\n\n## PHP Version Support Policy\n\nThis project currently supports the following PHP versions:\n\n- [PHP 7.4](https://www.php.net/releases/#7.4.0) (has reached its end of life on November 28, 2022)\n- [PHP 8.0](https://www.php.net/releases/#8.0.0) (has reached its end of life on November 26, 2023)\n- [PHP 8.1](https://www.php.net/releases/#8.1.0) (has reached its end of life on December 31, 2025)\n- [PHP 8.2](https://www.php.net/releases/#8.2.0)\n- [PHP 8.3](https://www.php.net/releases/#8.3.0)\n- [PHP 8.4](https://www.php.net/releases/#8.4.0)\n- [PHP 8.5](https://www.php.net/releases/#8.5.0)\n\nThe maintainers of this project add support for a PHP version following its initial release and _may_ drop support for a PHP version when it has reached its [end of life](https://www.php.net/supported-versions.php).\n\n## Security Policy\n\nThis project has a [security policy](.github/SECURITY.md).\n\n## License\n\nThis project uses the [MIT license](LICENSE.md).\n\n## Credits\n\nThis project is inspired by and also replaces [`localheinz/php-cs-fixer-config`](https://github.com/localheinz/php-cs-fixer-config).\n\nThis project requires and enables custom fixers from the following packages:\n\n- [`erickskrauch/php-cs-fixer-custom-fixers`](https://github.com/erickskrauch/php-cs-fixer-custom-fixers)\n- [`kubawerlos/php-cs-fixer-custom-fixers`](https://github.com/kubawerlos/php-cs-fixer-custom-fixers)\n\n## Social\n\nFollow [@localheinz](https://twitter.com/intent/follow?screen_name=localheinz) and [@ergebnis](https://twitter.com/intent/follow?screen_name=ergebnis) on Twitter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergebnis%2Fphp-cs-fixer-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fergebnis%2Fphp-cs-fixer-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergebnis%2Fphp-cs-fixer-config/lists"}