{"id":21466540,"url":"https://github.com/permafrost-dev/phpcsfixer-preset","last_synced_at":"2025-08-20T08:31:53.475Z","repository":{"id":50221262,"uuid":"306727871","full_name":"permafrost-dev/phpcsfixer-preset","owner":"permafrost-dev","description":"Use the same php-cs-fixer configuration across all of your projects, with presets for common project layouts (Laravel, Composer packages, etc.).","archived":false,"fork":false,"pushed_at":"2024-06-18T10:48:25.000Z","size":130,"stargazers_count":22,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-02T03:58:05.822Z","etag":null,"topics":["composer-package","laravel","laravel-package","php-cs-fixer","php-cs-fixer-config","php-cs-fixer-ruleset","presets"],"latest_commit_sha":null,"homepage":"https://permafrost.dev/open-source","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/permafrost-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"permafrost-dev"}},"created_at":"2020-10-23T19:22:34.000Z","updated_at":"2023-06-02T01:52:47.000Z","dependencies_parsed_at":"2024-11-19T05:45:11.159Z","dependency_job_id":null,"html_url":"https://github.com/permafrost-dev/phpcsfixer-preset","commit_stats":{"total_commits":131,"total_committers":4,"mean_commits":32.75,"dds":0.0992366412213741,"last_synced_commit":"dc7c657cc9d6434e9e8f59f218cdd968f92a1353"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/permafrost-dev/phpcsfixer-preset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Fphpcsfixer-preset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Fphpcsfixer-preset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Fphpcsfixer-preset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Fphpcsfixer-preset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/permafrost-dev","download_url":"https://codeload.github.com/permafrost-dev/phpcsfixer-preset/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Fphpcsfixer-preset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271287619,"owners_count":24733424,"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","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["composer-package","laravel","laravel-package","php-cs-fixer","php-cs-fixer-config","php-cs-fixer-ruleset","presets"],"created_at":"2024-11-23T08:14:25.113Z","updated_at":"2025-08-20T08:31:52.847Z","avatar_url":"https://github.com/permafrost-dev.png","language":"PHP","funding_links":["https://github.com/sponsors/permafrost-dev"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://static.permafrost.dev/images/phpcsfixer-preset/phpcsfixer-preset-logo-03.png\" alt=\"Permafrost Dev\" height=\"200\" style=\"block\"\u003e\n\u003cbr\u003e\u003cbr\u003e\n\u003cspan style=\"font-size:2.3rem\"\u003ephpcsfixer-preset\u003c/span\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/packagist/v/permafrost-dev/phpcsfixer-preset\" alt=\"version\"/\u003e \u003cimg src=\"https://img.shields.io/packagist/l/permafrost-dev/phpcsfixer-preset\" alt=\"license\"/\u003e \u003cimg src=\"https://img.shields.io/packagist/dt/permafrost-dev/phpcsfixer-preset\" alt=\"downloads\"/\u003e \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/permafrost-dev/phpcsfixer-preset/run-tests.yml?branch=main\" alt=\"Run Tests\"/\u003e \u003cimg  src=\"https://coveralls.io/repos/github/permafrost-dev/phpcsfixer-preset/badge.svg?branch=main\" alt=\"Coverage Status\" /\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n---\n\nThis package allows sharing identical [php-cs-fixer](https://github.com/FriendsOfPhp/PHP-CS-Fixer) formatting rules across all of your projects without copy-and-pasting configuration files. There is also a quick setup script to automatically generate a configuration file for the project structure and preferred formatting preset.\n\n`permafrost-dev/phpcsfixer-preset` provides several opinionated `php-cs-fixer` configuration choices as well as pre-configured `Finder` classes for common project formats and use cases.\n\nSupported PHP versions are `7.3`, `7.4`, `8.0`, `8.1`, and `8.2`.\n\nThe original concept for this package came from this excellent article on [sharing php-cs-fixer configurations across projects](https://laravel-news.com/sharing-php-cs-fixer-rules-across-projects-and-teams)  written by [Tim Mcdonald](https://timacdonald.me/).\n\n## Installation\n\n`composer require permafrost-dev/phpcsfixer-preset --dev`\n\n---\n\n## Example `.php-cs-fixer.dist.php` files\n\nThis example uses the Laravel project finder and the Default Ruleset:\n\n```php\n\u003c?php\n\nrequire_once(__DIR__ . '/vendor/autoload.php');\n\nuse Permafrost\\PhpCsFixerRules\\Finders\\LaravelProjectFinder;\nuse Permafrost\\PhpCsFixerRules\\Rulesets\\DefaultRuleset;\nuse Permafrost\\PhpCsFixerRules\\SharedConfig;\n\n$finder = LaravelProjectFinder::create(__DIR__);\n\nreturn SharedConfig::create($finder, new DefaultRuleset());\n```\n\nStandard `PhpCsFixer\\Finder` options can be chained onto the custom `Finder` class to customize it to your preferences:\n\n```php\n    // ...\n    $finder = LaravelProjectFinder::create(__DIR__)\n        -\u003ein([__DIR__ . '/custom-src-dir'])\n        -\u003enotName('*.ignored.php')\n        -\u003enotPath('another-custom-dir/cache/*');\n    // ...\n```\n\nThe standard `PhpCsFixer\\Finder` class can be used along with any of the Rulesets:\n\n```php\n\u003c?php\n\nrequire_once(__DIR__ . '/vendor/autoload.php');\n\nuse PhpCsFixer\\Finder;\nuse Permafrost\\PhpCsFixerRules\\Rulesets\\SpatieRuleset;\nuse Permafrost\\PhpCsFixerRules\\SharedConfig;\n\n$finder = Finder::create()\n    -\u003eignoreVCS(true)\n    -\u003eignoreDotFiles(true)\n    -\u003ename('*.php')\n    -\u003ein([\n        __DIR__ . '/src',\n        __DIR__ . '/tests',\n    ])\n    -\u003eexclude(__DIR__ . '/vendor');\n\nreturn SharedConfig::create($finder, new SpatieRuleset());\n```\n\n---\n\n## Overriding Ruleset Rules\n\nWhen creating a `Ruleset` class, you may pass an array of `php-cs-fixer` rules that add or override the Ruleset's default rules.\n\n```php\n\u003c?php\n\nrequire_once(__DIR__.'/vendor/autoload.php');\n\nuse Permafrost\\PhpCsFixerRules\\Finders\\LaravelProjectFinder;\nuse Permafrost\\PhpCsFixerRules\\Rulesets\\DefaultRuleset;\nuse Permafrost\\PhpCsFixerRules\\SharedConfig;\n\n$finder = LaravelProjectFinder::create(__DIR__);\n\nreturn SharedConfig::create($finder, new DefaultRuleset([\n    // existing rules can be overridden:\n    'no_break_comment' =\u003e true,\n    'no_closing_tag' =\u003e false,\n    // new rules can be added:\n    'a_new_option' =\u003e [\n        'some_sub_option' =\u003e 12,\n    ],\n]));\n```\n\n---\n\n## Quick Setup\n\nTo generate a `php-cs-fixer` configuration file for your project, run:\n\n```bash\nvendor/bin/pf-create-cs-config \u003ctype\u003e [-o|--outfile=filename] [-r|--ruleset=name] [-f|--force]\n```\n\nParameter: `\u003ctype\u003e`\n\nRequired: **yes**\n\nDefault: _no default_\n\nPossible values:\n\n- `custom`\n- `project`\n- `package`\n- `laravel` _(alias for laravel:project)_\n- `laravel:project`\n- `laravel:package`\n\nFlag: `--outfile` (or `-o`)\n\nRequired: **no**\n\nDefault: `.php-cs-fixer.dist.php`\n\nPossible values: any valid filename\n\nFlag: `--ruleset` (or `-r`)\u003cbr\u003e\n\nRequired: **no**\u003cbr\u003e\n\nDefault: `default`\u003cbr\u003e\n\nPossible values:\u003cbr\u003e\n\n- `default`\n- `laravel_shift`\n- `php_unit`\n- `spatie`\n\nFlag: `--force` (or `-f`)\u003cbr\u003e\n\nRequired: **no**\u003cbr\u003e\n\nDefault: `false`\u003cbr\u003e\n\nPossible values: none\u003cbr\u003e\n\nEffect: overwrites any existing configuration file\u003cbr\u003e\n\nExamples:\n\n```bash\nvendor/bin/pf-create-cs-config laravel:package\n\nvendor/bin/pf-create-cs-config package -f\n\nvendor/bin/pf-create-cs-config laravel -o .php-cs-fixer.php -r spatie\n\nvendor/bin/pf-create-cs-config project --ruleset=laravel_shift\n\nvendor/bin/pf-create-cs-config custom --outfile=.my-config\n```\n\n**Note on the `custom` type:**\n\nThe `custom` type will prompt you to enter the directory names you would like `php-cs-fixer` to include and exclude. The generated configuration file implements the `PhpCsFixer\\Finder` class instead of one of the preconfigured finder classes.\n\n---\n\n## Automatic Formatting\n\nTo apply `php-cs-fixer` formatting using Github Actions automatically, see the [automation with Github Actions](docs/automation.md) documentation.\n\n---\n\n## [Finder Presets](docs/finders.md)\n\n#### `BasicProjectFinder`\n\n- ignores VCS files\n- ignores dotfiles\n- includes PHP files\n- excludes `vendor/` directory\n\n#### `LaravelProjectFinder`\n\n- inherits [`BasicProjectFinder`](#basicprojectfinder) presets\n- excludes `*.blade.php` files\n- excludes all files in `bootstrap/`, `public/`, `resources/`, `storage/`\n- includes PHP files in `app/`, `config/`, `database/`, `routes/`, `tests/`\n\n#### `LaravelPackageFinder`\n\n- inherits [`BasicProjectFinder`](#basicprojectfinder) presets\n- excludes `*.blade.php` files\n- excludes all files in `resources/`\n- includes PHP files in `src/`, `tests/`, `config/`\n\n#### `ComposerPackageFinder`\n\n- inherits [`BasicProjectFinder`](#basicprojectfinder) presets\n- includes PHP files in `src/`, `tests/`\n\n---\n\n## [Rulesets](docs/rulesets/index.md)\n\n#### `Default`\n\n- Default opinionated Ruleset provided by this package.\n- [View Rules](docs/rulesets/default_rules.md)\n\n#### `LaravelShift`\n\n- Ruleset used by [Laravel Shift](https://laravelshift.com).\n- [View Rules](docs/rulesets/laravel_shift_rules.md)\n\n#### `PhpUnit`\n\n- Ruleset used by [PHPUnit](https://github.com/sebastianbergmann/phpunit).\n- [View Rules](docs/rulesets/php_unit_rules.md)\n\n#### `Spatie`\n\n- Ruleset used by [Spatie](https://github.com/spatie).\n- [View Rules](docs/rulesets/spatie_rules.md)\n\n\u003cbr\u003e\n\n---\n\n## Usage\n\nSelect a Finder preset or create an instance of `\\PhpCsFixer\\Finder` and return `SharedConfig::create($finder)` from the `.php-cs-fixer.dist.php` file.\n\n## Updating Default Rules\n\nUpdate the `rules()` method in the `Permafrost\\PhpCsFixerRules\\Rulesets\\DefaultRuleset` class.\n\n## Creating Rulesets\n\nCreate a class that implements the `Permafrost\\PhpCsFixerRules\\Rulesets\\Ruleset` interface, returning your rules from the `rules()` method.\n\nSample Ruleset:\n\n```php\n\u003c?php\n\nnamespace Permafrost\\PhpCsFixerRules\\Rulesets;\n\nclass MyCustomRulesRuleset implements RuleSet\n{\n    public function allowRisky(): bool\n    {\n        return true; //this tells php-cs-fixer whether or not to permit \"risky\" rules.\n    }\n\n    public static function name(): string\n    {\n        return 'my_custom_rules'; //the name should omit 'ruleset' from the end.\n    }\n\n    /**\n     * @return array\n     */\n    public function rules(): array\n    {\n        return array_merge([\n            '@PSR2' =\u003e true,\n            // additional php-cs-fixer rules\n        ], $this-\u003eadditional); //it's important that the additional rules property is merged\n    }\n}\n```\n\nIf adding a new Ruleset to this package, the Ruleset must be registered in `\\Permafrost\\PhpCsFixerRules\\Commands\\GenerateConfigCommand@rulesets()` to allow the quick setup command to use it.\n\nWhen creating a new Ruleset package, follow the above example but use a namespace unique to the package.\n\n---\n\n## Code Formatting\n\nTo format all files specified in the configuration, run:\n\n`vendor/bin/php-cs-fixer fix`\n\nTo list the files to be processed without making any changes:\n\n`vendor/bin/php-cs-fixer fix  --dry-run`\n\n---\n\n## Testing\n\nThis package uses PHPUnit for unit tests. To run the test suite, run:\n\n`./vendor/bin/phpunit`\n\n---\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n---\n\n## Contributions\n\nContributions of `Rulesets`, `Finders`, bug fixes, suggestions, or improvements are welcome. Please open an appropriately labeled issue or pull request for any of these.\n\n---\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermafrost-dev%2Fphpcsfixer-preset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpermafrost-dev%2Fphpcsfixer-preset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermafrost-dev%2Fphpcsfixer-preset/lists"}