{"id":20180549,"url":"https://github.com/ergebnis/php-cs-fixer-config-template","last_synced_at":"2025-04-10T04:57:29.829Z","repository":{"id":36327044,"uuid":"223454743","full_name":"ergebnis/php-cs-fixer-config-template","owner":"ergebnis","description":":octocat: + :notebook: Provides a GitHub repository template for a configuration factory and rule set factories for friendsofphp/php-cs-fixer.","archived":false,"fork":false,"pushed_at":"2024-10-23T20:50:10.000Z","size":4038,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-24T08:41:44.629Z","etag":null,"topics":["configuration","php-cs-fixer","template"],"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":".github/CODE_OF_CONDUCT.md","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}},"created_at":"2019-11-22T17:39:09.000Z","updated_at":"2024-10-23T20:50:14.000Z","dependencies_parsed_at":"2023-01-17T00:30:40.360Z","dependency_job_id":"24541f99-3e15-4214-b00a-e44bb262268e","html_url":"https://github.com/ergebnis/php-cs-fixer-config-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":"ergebnis/php-package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphp-cs-fixer-config-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphp-cs-fixer-config-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphp-cs-fixer-config-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphp-cs-fixer-config-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ergebnis","download_url":"https://codeload.github.com/ergebnis/php-cs-fixer-config-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161264,"owners_count":21057554,"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","template"],"created_at":"2024-11-14T02:31:43.053Z","updated_at":"2025-04-10T04:57:29.818Z","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-template\n\n[![Integrate](https://github.com/ergebnis/php-cs-fixer-config-template/workflows/Integrate/badge.svg)](https://github.com/ergebnis/php-cs-fixer-config-template/actions)\n[![Merge](https://github.com/ergebnis/php-cs-fixer-config-template/workflows/Merge/badge.svg)](https://github.com/ergebnis/php-cs-fixer-config-template/actions)\n[![Release](https://github.com/ergebnis/php-cs-fixer-config-template/workflows/Release/badge.svg)](https://github.com/ergebnis/php-cs-fixer-config-template/actions)\n[![Renew](https://github.com/ergebnis/php-cs-fixer-config-template/workflows/Renew/badge.svg)](https://github.com/ergebnis/php-cs-fixer-config-template/actions)\n\n[![Code Coverage](https://codecov.io/gh/ergebnis/php-cs-fixer-config-template/branch/main/graph/badge.svg)](https://codecov.io/gh/ergebnis/php-cs-fixer-config-template)\n\n[![Latest Stable Version](https://poser.pugx.org/ergebnis/php-cs-fixer-config-template/v/stable)](https://packagist.org/packages/ergebnis/php-cs-fixer-config-template)\n[![Total Downloads](https://poser.pugx.org/ergebnis/php-cs-fixer-config-template/downloads)](https://packagist.org/packages/ergebnis/php-cs-fixer-config-template)\n[![Monthly Downloads](http://poser.pugx.org/ergebnis/php-cs-fixer-config-template/d/monthly)](https://packagist.org/packages/ergebnis/php-cs-fixer-config-template)\n\nThis project provides a [GitHub repository template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) for 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-template\n```\n\n## Usage\n\n### Configuration\n\nPick one of the rule sets:\n\n- [`Ergebnis\\PhpCsFixer\\RuleSet\\Custom`](src/RuleSet/Custom.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;\n\n$ruleSet = Config\\RuleSet\\Custom::create();\n\n$config = Config\\Factory::fromRuleSet($ruleSet);\n\n$config-\u003egetFinder()-\u003ein(__DIR__);\n$config-\u003esetCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');\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\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-template\n+EOF;\n\n-$ruleSet = Config\\RuleSet\\Custom::create();\n+$ruleSet = Config\\RuleSet\\Custom::create()-\u003ewithHeader($header);\n\n $config = Config\\Factory::fromRuleSet($ruleSet);\n\n $config-\u003egetFinder()-\u003ein(__DIR__);\n $config-\u003esetCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');\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\n-$ruleSet = Config\\RuleSet\\Custom::create();\n+$ruleSet = Config\\RuleSet\\Custom::create()-\u003ewithRules(Config\\Rules::fromArray([\n+    'mb_str_functions' =\u003e false,\n+    'strict_comparison' =\u003e false,\n+]));\n\n $config = Config\\Factory::fromRuleSet($ruleSet);\n\n $config-\u003egetFinder()-\u003ein(__DIR__);\n $config-\u003esetCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');\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\n-$ruleSet = Config\\RuleSet\\Custom::create();\n+$ruleSet = Config\\RuleSet\\Custom::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 $config = Config\\Factory::fromRuleSet($ruleSet);\n\n $config-\u003egetFinder()-\u003ein(__DIR__);\n $config-\u003esetCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');\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-template\": \"~1.0.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](.github/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 @localheinz](https://github.com/sponsors/localheinz) or [requesting an invoice for services related to this project](mailto:am@localheinz.com?subject=ergebnis/php-cs-fixer-config-template:%20Requesting%20invoice%20for%20services).\n\n## PHP Version Support Policy\n\nThis project supports PHP versions with [active and security support](https://www.php.net/supported-versions.php).\n\nThe maintainers of this project add support for a PHP version following its initial release and drop support for a PHP version when it has reached the end of security support.\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 [`ergebnis/php-cs-fixer-config`](https://github.com/ergebnis/php-cs-fixer-config).\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-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fergebnis%2Fphp-cs-fixer-config-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergebnis%2Fphp-cs-fixer-config-template/lists"}