{"id":19665915,"url":"https://github.com/amphp/php-cs-fixer-config","last_synced_at":"2025-04-28T22:31:29.929Z","repository":{"id":56947326,"uuid":"139071108","full_name":"amphp/php-cs-fixer-config","owner":"amphp","description":"Common code style configuration for all @amphp projects.","archived":false,"fork":false,"pushed_at":"2024-04-19T02:37:37.000Z","size":27,"stargazers_count":9,"open_issues_count":0,"forks_count":5,"subscribers_count":8,"default_branch":"2.x","last_synced_at":"2025-04-05T11:34:17.920Z","etag":null,"topics":["amphp","code-style","php","phpcs","psr-2"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-06-28T21:43:32.000Z","updated_at":"2025-03-02T14:30:04.000Z","dependencies_parsed_at":"2024-04-19T03:26:29.887Z","dependency_job_id":null,"html_url":"https://github.com/amphp/php-cs-fixer-config","commit_stats":{"total_commits":28,"total_committers":4,"mean_commits":7.0,"dds":0.3928571428571429,"last_synced_commit":"a06b2541db61a8b8422b0a3e40d54047e8d242c8"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fphp-cs-fixer-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fphp-cs-fixer-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fphp-cs-fixer-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fphp-cs-fixer-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amphp","download_url":"https://codeload.github.com/amphp/php-cs-fixer-config/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251397605,"owners_count":21583041,"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":["amphp","code-style","php","phpcs","psr-2"],"created_at":"2024-11-11T16:25:27.096Z","updated_at":"2025-04-28T22:31:27.668Z","avatar_url":"https://github.com/amphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-cs-fixer-config\n\nThis repository contains the common code style configuration for all [**@amphp**](https://github.com/amphp) projects.\nIt's based on the ideas of [`refinery29/php-cs-fixer-config`](https://github.com/refinery29/php-cs-fixer-config/).\n\n[![Build Status](https://travis-ci.org/amp/php-cs-fixer-config.svg?branch=master)](https://travis-ci.org/amp/php-cs-fixer-config)\n\n## Installation\n\n```\ncomposer require --dev amphp/php-cs-fixer-config\n```\n\n## Usage\n\n### Configuration\n\nCreate a configuration file `.php_cs.dist` in the root of the project:\n\n```php\n\u003c?php\n\n$config = new Amp\\CodeStyle\\Config;\n$config-\u003egetFinder()\n    -\u003ein(__DIR__ . \"/examples\")\n    -\u003ein(__DIR__ . \"/src\")\n    -\u003ein(__DIR__ . \"/test\");\n\n$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;\n$config-\u003esetCacheFile($cacheDir . '/.php_cs.cache');\n\nreturn $config;\n```\n\n### Git\n\nAdd `.php_cs.cache` (the cache file used by `php-cs-fixer`) to `.gitignore`:\n\n```\nvendor/\n.php_cs.cache\n```\n\n### Travis\n\nUpdate your `.travis.yml` to cache the `php_cs.cache` file:\n\n```yml\ncache:\n  directories:\n    - $HOME/.php-cs-fixer\n```\n\nThen run `php-cs-fixer` in the `script` section:\n\n```yml\nscript:\n  - vendor/bin/php-cs-fixer fix --config=.php_cs.dist --verbose --diff --dry-run\n```\n\n## Fixing issues\n\n### Manually\n\nIf you need to fix issues locally, run\n\n```\n./vendor/bin/php-cs-fixer fix -v\n```\n\n### Pre-commit hook\n\nYou can add a `pre-commit` hook to format the code automatically before each commit.\n\nRun `touch .git/pre-commit` to create a new hook, make it executable with `chmod +x .git/pre-commit` and paste the following script into `.git/pre-commit`:\n\n```bash\n#!/usr/bin/env bash\n\necho \"Running php-cs-fixer to format the code...\"\n\nCURRENT_DIRECTORY=`pwd`\nGIT_HOOKS_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" \u0026\u0026 pwd )\"\n\nPROJECT_DIRECTORY=\"$GIT_HOOKS_DIR/../..\"\n\ncd $PROJECT_DIRECTORY;\nPHP_CS_FIXER=\"vendor/bin/php-cs-fixer\"\n\nHAS_PHP_CS_FIXER=false\n\nif [ -x \"$PHP_CS_FIXER\" ]; then\n    HAS_PHP_CS_FIXER=true\nfi\n\nif $HAS_PHP_CS_FIXER; then\n    git status --porcelain | grep -e '^[AM]\\(.*\\).php$' | cut -c 3- | while read line; do\n        ${PHP_CS_FIXER} fix --config-file=.php_cs --verbose ${line};\n        git add \"$line\";\n    done\nelse\n    echo \"\"\n    echo \"Please install php-cs-fixer, e.g.:\"\n    echo \"\"\n    echo \"  composer require friendsofphp/php-cs-fixer:2.0.0\"\n    echo \"\"\nfi\n\ncd $CURRENT_DIRECTORY;\necho \"Done.\"\n```\n\n## License\n\nThis package is licensed using the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famphp%2Fphp-cs-fixer-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famphp%2Fphp-cs-fixer-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famphp%2Fphp-cs-fixer-config/lists"}