{"id":15062703,"url":"https://github.com/phpcsstandards/composer-installer","last_synced_at":"2025-05-14T17:05:19.830Z","repository":{"id":37768675,"uuid":"71593418","full_name":"PHPCSStandards/composer-installer","owner":"PHPCSStandards","description":"Composer installer for PHP_CodeSniffer coding standards","archived":false,"fork":false,"pushed_at":"2025-05-02T16:24:11.000Z","size":483,"stargazers_count":578,"open_issues_count":8,"forks_count":37,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-14T17:04:28.580Z","etag":null,"topics":["coding-standards","composer-installation","composer-plugin","php-codesniffer","phpcodesniffer-standard"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer","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/PHPCSStandards.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null},"funding":{"open_collective":"php_codesniffer","github":["PHPCSStandards","jrfnl"],"thanks_dev":"u/gh/phpcsstandards"}},"created_at":"2016-10-21T20:14:16.000Z","updated_at":"2025-05-05T05:26:09.000Z","dependencies_parsed_at":"2023-09-22T13:31:58.297Z","dependency_job_id":"b7c863d7-65cf-442f-9d46-33ca251d8ca2","html_url":"https://github.com/PHPCSStandards/composer-installer","commit_stats":{"total_commits":257,"total_committers":28,"mean_commits":9.178571428571429,"dds":"0.47470817120622566","last_synced_commit":"c4a245221d23aa141ae985122b7d59aace4d4d2d"},"previous_names":["dealerdirect/phpcodesniffer-composer-installer"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPCSStandards%2Fcomposer-installer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPCSStandards%2Fcomposer-installer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPCSStandards%2Fcomposer-installer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPCSStandards%2Fcomposer-installer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PHPCSStandards","download_url":"https://codeload.github.com/PHPCSStandards/composer-installer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254190396,"owners_count":22029632,"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":["coding-standards","composer-installation","composer-plugin","php-codesniffer","phpcodesniffer-standard"],"created_at":"2024-09-24T23:44:53.367Z","updated_at":"2025-05-14T17:05:19.792Z","avatar_url":"https://github.com/PHPCSStandards.png","language":"PHP","readme":"# PHP_CodeSniffer Standards Composer Installer Plugin\n\n![Last Commit][last-updated-shield]\n![Awesome][awesome-shield]\n[![License][license-shield]](LICENSE.md)\n\n[![Tests][ghactionstest-shield]][ghactions]\n[![Latest Version on Packagist][packagist-version-shield]][packagist-version]\n[![Packagist][packagist-shield]][packagist]\n\n[![Contributor Covenant][code-of-conduct-shield]][code-of-conduct]\n\nThis composer installer plugin allows for easy installation of [PHP_CodeSniffer][codesniffer] coding standards (rulesets).\n\nNo more symbolic linking of directories, checking out repositories on specific locations or changing\nthe `phpcs` configuration.\n\n## Usage\n\nInstallation can be done with [Composer][composer], by requiring this package as a development dependency:\n\n```bash\ncomposer require --dev dealerdirect/phpcodesniffer-composer-installer:\"^1.0\"\n```\n\nSince Composer 2.2, Composer will [ask for your permission](https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution) to allow this plugin to execute code. For this plugin to be functional, permission needs to be granted.\n\nWhen permission has been granted, the following snippet will automatically be added to your `composer.json` file by Composer:\n```json\n{\n    \"config\": {\n        \"allow-plugins\": {\n            \"dealerdirect/phpcodesniffer-composer-installer\": true\n        }\n    }\n}\n```\n\nYou can safely add the permission flag (to avoid Composer needing to ask), by running:\n```bash\ncomposer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true\n```\n\nThat's it.\n\n### Compatibility\n\nThis plugin is compatible with:\n\n- PHP **5.4+**, **7.x**, and **8.x** (Support for PHP v8 is available since [`v0.7.0`][v0.7])\n- [Composer][composer] **2.2+** (Support for Composer v2 is available since [`v0.7.0`][v0.7]; support for Composer \u003c 2.2 was dropped in [`v1.1.0`][v1.1])\n- [PHP_CodeSniffer][codesniffer] **2.x** and **3.x** (Support for PHP_CodeSniffer v3 is available since [`v0.4.0`][v0.4])\n\n### How it works\n\nBasically, this plugin executes the following steps:\n\n- This plugin searches for [`phpcodesniffer-standard` packages][] in all of your currently installed Composer packages.\n- Matching packages and the project itself are scanned for PHP_CodeSniffer rulesets.\n- The plugin will call PHP_CodeSniffer and configure the `installed_paths` option.\n\n### Example project\n\nThe following is an example Composer project and has included\nmultiple `phpcodesniffer-standard` packages.\n\n```json\n{\n    \"name\": \"example/project\",\n    \"description\": \"Just an example project\",\n    \"type\": \"project\",\n    \"require\": {},\n    \"require-dev\": {\n        \"dealerdirect/phpcodesniffer-composer-installer\": \"*\",\n        \"object-calisthenics/phpcs-calisthenics-rules\": \"*\",\n        \"phpcompatibility/php-compatibility\": \"*\",\n        \"wp-coding-standards/wpcs\": \"*\"\n    },\n    \"config\": {\n        \"allow-plugins\": {\n            \"dealerdirect/phpcodesniffer-composer-installer\": true\n        }\n    }\n}\n```\n\nAfter running `composer install` PHP_CodeSniffer just works:\n\n```bash\n$ ./vendor/bin/phpcs -i\nThe installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend, ObjectCalisthenics,\nPHPCompatibility, WordPress, WordPress-Core, WordPress-Docs and WordPress-Extra\n```\n\n### Calling the plugin directly\n\nIn some circumstances, it is desirable to call this plugin's functionality\ndirectly. For instance, during development or in [CI][definition-ci] environments.\n\nAs the plugin requires Composer to work, direct calls need to be wired through a\nproject's `composer.json`.\n\nThis is done by adding a call to the `Plugin::run` function in the `script`\nsection of the `composer.json`:\n\n```json\n{\n    \"scripts\": {\n        \"install-codestandards\": [\n            \"PHPCSStandards\\\\Composer\\\\Plugin\\\\Installers\\\\PHPCodeSniffer\\\\Plugin::run\"\n        ]\n    }\n}\n```\n\nThe command can then be called using `composer run-script install-codestandards` or\nreferenced from other script configurations, as follows:\n\n```json\n{\n    \"scripts\": {\n        \"install-codestandards\": [\n            \"PHPCSStandards\\\\Composer\\\\Plugin\\\\Installers\\\\PHPCodeSniffer\\\\Plugin::run\"\n        ],\n        \"post-install-cmd\": [\n            \"@install-codestandards\"\n        ]\n    }\n}\n```\n\nFor more details about Composer scripts, please refer to [the section on scripts\nin the Composer manual][composer-manual-scripts].\n\n### Changing the Coding Standards search depth\n\nBy default, this plugin searches up for Coding Standards up to three directories\ndeep. In most cases, this should be sufficient. However, this plugin allows\nyou to customize the search depth setting if needed.\n\n```json\n{\n    \"extra\": {\n        \"phpcodesniffer-search-depth\": 5\n    }\n}\n```\n\n### Caveats\n\nWhen this plugin is installed globally, composer will load the _global_ plugin rather\nthan the one from the local repository. Despite [this behavior being documented\nin the composer manual][using-composer-plugins], it could potentially confuse\nas another version of the plugin could be run and not the one specified by the project.\n\n## Developing Coding Standards\n\nCoding standard can be developed normally, as documented by [PHP_CodeSniffer][codesniffer], in the [Coding Standard Tutorial][tutorial].\n\nCreate a composer package of your coding standard by adding a `composer.json` file.\n\n```json\n{\n  \"name\" : \"acme/phpcodesniffer-our-standards\",\n  \"description\" : \"Package contains all coding standards of the Acme company\",\n  \"require\" : {\n    \"php\" : \"\u003e=5.4.0\",\n    \"squizlabs/php_codesniffer\" : \"^3.6\"\n  },\n  \"type\" : \"phpcodesniffer-standard\"\n}\n```\n\nRequirements:\n* The repository may contain one or more standards.\n* Each standard can have a separate directory no deeper than 3 levels from the repository root.\n* The package `type` must be `phpcodesniffer-standard`. Without this, the plugin will not trigger.\n\n### Requiring the plugin from within your coding standard\n\nIf your coding standard itself depends on additional external PHPCS standards, this plugin can\nmake life easier on your end-users by taking care of the installation of all standards - yours\nand your dependencies - for them.\n\nThis can help reduce the number of support questions about setting the `installed_paths`, as well\nas simplify your standard's installation instructions.\n\nFor this to work, make sure your external standard adds this plugin to the `composer.json` config\nvia `require`, **not** `require-dev`.\n\n\u003e :warning: Your end-user may already `require-dev` this plugin and/or other external standards used\n\u003e by your end-users may require this plugin as well.\n\u003e\n\u003e To prevent your end-users getting into \"_dependency hell_\", make sure to make the version requirement\n\u003e for this plugin flexible.\n\u003e\n\u003e Remember that [Composer treats unstable minors as majors][composer-manual-caret] and will not be able to resolve\n\u003e one config requiring this plugin at version `^0.7`, while another requires it at version `^1.0`.\n\u003e Either allow multiple minors or use `*` as the version requirement.\n\u003e\n\u003e Some examples of flexible requirements which can be used:\n\u003e ```bash\n\u003e composer require dealerdirect/phpcodesniffer-composer-installer:\"*\"\n\u003e composer require dealerdirect/phpcodesniffer-composer-installer:\"^0.4.1 || ^0.5 || ^0.6 || ^0.7 || ^1.0\"\n\u003e ```\n\n## Changelog\n\nThis repository does not contain a `CHANGELOG.md` file, however, we do publish a changelog on each release\nusing the [GitHub releases][changelog] functionality.\n\n## Contributing\n\nThis is an active open-source project. We are always open to people who want to\nuse the code or contribute to it.\n\nWe've set up a separate document for our [contribution guidelines][contributing-guidelines].\n\nThank you for being involved! :heart_eyes:\n\n## Authors \u0026 contributors\n\nThe original idea and setup of this repository is by [Franck Nijhof][frenck], employee @ Dealerdirect.\n\nFor a full list of all authors and/or contributors, check [the contributors page][contributors].\n\n## Funding\n\nThis project is included in the projects supported via the [PHP_CodeSniffer Open Collective][phpcs-open-collective].\n\nIf you use this plugin, financial contributions to the Open Collective are encouraged and appreciated.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016-2022 Dealerdirect B.V. and contributors\nCopyright (c) 2022- PHPCSStandards and contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n[awesome-shield]: https://img.shields.io/badge/awesome%3F-yes-brightgreen.svg\n[changelog]: https://github.com/PHPCSStandards/composer-installer/releases\n[code-of-conduct-shield]: https://img.shields.io/badge/Contributor%20Covenant-v2.0-ff69b4.svg\n[code-of-conduct]: CODE_OF_CONDUCT.md\n[codesniffer]: https://github.com/PHPCSStandards/PHP_CodeSniffer\n[composer-manual-scripts]: https://getcomposer.org/doc/articles/scripts.md\n[composer-manual-caret]: https://getcomposer.org/doc/articles/versions.md#caret-version-range-\n[composer]: https://getcomposer.org/\n[contributing-guidelines]: CONTRIBUTING.md\n[contributors]: https://github.com/PHPCSStandards/composer-installer/graphs/contributors\n[definition-ci]: https://en.wikipedia.org/wiki/Continuous_integration\n[frenck]: https://github.com/frenck\n[last-updated-shield]: https://img.shields.io/github/last-commit/PHPCSStandards/composer-installer.svg\n[license-shield]: https://img.shields.io/github/license/PHPCSStandards/composer-installer.svg\n[packagist-shield]: https://img.shields.io/packagist/dt/dealerdirect/phpcodesniffer-composer-installer.svg\n[packagist-version-shield]: https://img.shields.io/packagist/v/dealerdirect/phpcodesniffer-composer-installer.svg\n[packagist-version]: https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer\n[packagist]: https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer\n[`phpcodesniffer-standard` packages]: https://packagist.org/explore/?type=phpcodesniffer-standard\n[phpcs-open-collective]: https://opencollective.com/php_codesniffer\n[scrutinizer-shield]: https://img.shields.io/scrutinizer/g/dealerdirect/phpcodesniffer-composer-installer.svg\n[scrutinizer]: https://scrutinizer-ci.com/g/dealerdirect/phpcodesniffer-composer-installer/\n[ghactionstest-shield]: https://github.com/PHPCSStandards/composer-installer/actions/workflows/integrationtest.yml/badge.svg\n[ghactions]: https://github.com/PHPCSStandards/composer-installer/actions/workflows/integrationtest.yml\n[tutorial]: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial\n[using-composer-plugins]: https://getcomposer.org/doc/articles/plugins.md#using-plugins\n[v0.4]: https://github.com/PHPCSStandards/composer-installer/releases/tag/v0.4.0\n[v0.7]: https://github.com/PHPCSStandards/composer-installer/releases/tag/v0.7.0\n[v1.1]: https://github.com/PHPCSStandards/composer-installer/releases/tag/v1.1.0\n","funding_links":["https://opencollective.com/php_codesniffer","https://github.com/sponsors/PHPCSStandards","https://github.com/sponsors/jrfnl","https://thanks.dev/u/gh/phpcsstandards"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpcsstandards%2Fcomposer-installer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpcsstandards%2Fcomposer-installer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpcsstandards%2Fcomposer-installer/lists"}