{"id":39567307,"url":"https://github.com/weerd/php-style","last_synced_at":"2026-01-18T07:15:19.679Z","repository":{"id":54507228,"uuid":"285135745","full_name":"weerd/php-style","owner":"weerd","description":"Shareable pre-configured base style rules for the PHP Code Standards Fixer tool.","archived":false,"fork":false,"pushed_at":"2021-02-15T00:20:33.000Z","size":30,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T22:38:51.594Z","etag":null,"topics":["laravel","php-cs-fixer","php-styles"],"latest_commit_sha":null,"homepage":"","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/weerd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-05T00:36:34.000Z","updated_at":"2023-03-07T14:27:14.000Z","dependencies_parsed_at":"2022-08-13T18:10:20.257Z","dependency_job_id":null,"html_url":"https://github.com/weerd/php-style","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/weerd/php-style","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weerd%2Fphp-style","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weerd%2Fphp-style/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weerd%2Fphp-style/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weerd%2Fphp-style/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weerd","download_url":"https://codeload.github.com/weerd/php-style/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weerd%2Fphp-style/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28532808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"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":["laravel","php-cs-fixer","php-styles"],"created_at":"2026-01-18T07:15:18.682Z","updated_at":"2026-01-18T07:15:19.664Z","avatar_url":"https://github.com/weerd.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e✨ PHP Styles ✨\u003c/h1\u003e\n\nThis package provides a simple way to apply pre-configured base style rules for the [PHP Code Standards Fixer tool](https://cs.symfony.com/), that can be easily shared across projects and packages using PHP 7+.\n\nIt can be configured using the `default` rules or you can specify a different supported base ruleset, along with any additional rules or overrides you would like to include.\n\n## Installation\n\n```\n$ composer require weerd/php-style\n```\n\n## Usage\n\nAdd a `.php_cs.dist` in the root directory of your project or pacakge.\n\nWithin that file create a new instance of `PhpCsFixer\\Finder` and configure what files and directories the PHP CS Fixer tool should be looking to fix code style.\n\nNext, call the `Weerd\\PhpStyle\\configure()` function and pass the instance of the finder as the first argument.\n\nBelow are some examples along with variations utilizing the `$options` array:\n\n### Example using default ruleset\n\nThe following example returns a configuration with the [default](https://github.com/weerd/php-style/blob/master/src/rules/default.php) rules for PHP styles.\n\n```php\n\u003c?php\n\nuse PhpCsFixer\\Finder;\nuse function Weerd\\PhpStyle\\configure;\n\n$finder = Finder::create()\n    -\u003ein([\n        __DIR__.'/src',\n        __DIR__.'/tests',\n    ]);\n\nreturn configure($finder);\n```\n\n### Example using default ruleset and additional rules\n\nThe following example returns a configuration with the [default](https://github.com/weerd/php-style/blob/master/src/rules/default.php) rules, along with two additional rules included in the final set of rules for PHP styles.\n\n```php\n\u003c?php\n\nuse PhpCsFixer\\Finder;\nuse function Weerd\\PhpStyle\\configure;\n\n$finder = Finder::create()\n    -\u003ein([\n        __DIR__.'/src',\n        __DIR__.'/tests',\n    ]);\n\n$options = [\n  'rules' =\u003e [\n    'single_quote' =\u003e true,\n    'trim_array_spaces' =\u003e true,\n  ],\n];\n\nreturn configure($finder, $options);\n```\n\n### Example using laravel ruleset\n\nThe following example returns a configuration with the [laravel](https://github.com/weerd/php-style/blob/master/src/rules/laravel.php) rules for PHP styles.\n\n```php\n\u003c?php\n\nuse PhpCsFixer\\Finder;\nuse function Weerd\\PhpStyle\\configure;\n\n$finder = Finder::create()\n    -\u003ein([\n        __DIR__.'/app',\n        __DIR__.'/config',\n        __DIR__.'/database',\n        __DIR__.'/routes',\n        __DIR__.'/tests',\n    ])\n    -\u003enotName('*.blade.php');\n\nreturn configure($finder, ['base' =\u003e 'laravel']);\n```\n\nOnce you have the `.php_cs.dist` file setup, you can run the PHP CS Fixer tool by running:\n\n```bash\n$ vendor/bin/php-cs-fixer fix --allow-risky=yes\n```\n\nOr to make things easier, add that command to the `composer.json` file as a script:\n\n```json\n// composer.json\n\n{\n    \"scripts\": {\n        \"format\": \"vendor/bin/php-cs-fixer fix --allow-risky=yes\"\n    }\n}\n```\n\nNow you can run the PHP CS Fixer tool with the following composer command:\n\n```bash\n$ composer format\n```\n\n\n## Credits\n\n🙌 Thanks to [@Spatie](https://github.com/spatie) and their [Laravel Package Training](https://laravelpackage.training/) course for introducing me to the PHP Code Standards Fixer tool and how to use it!\n\n🙌 This package is heavily inspired by [@timacdonald's](https://github.com/timacdonald) great article on [how to share PHP CS Fixer rules](https://laravel-news.com/sharing-php-cs-fixer-rules-across-projects-and-teams)!\n\n🙌 The complete set of Laravel specific rules are thanks to [@laravel-shift](https://gist.github.com/laravel-shift) and the compiled rules shared in a [gist](https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200) and used on [Laravel Shift](https://laravelshift.com/)!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweerd%2Fphp-style","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweerd%2Fphp-style","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweerd%2Fphp-style/lists"}