{"id":13803271,"url":"https://github.com/bamarni/composer-bin-plugin","last_synced_at":"2026-01-30T01:26:46.563Z","repository":{"id":43636775,"uuid":"57874945","full_name":"bamarni/composer-bin-plugin","owner":"bamarni","description":"No conflicts for your bin dependencies","archived":false,"fork":false,"pushed_at":"2024-11-05T11:41:17.000Z","size":161,"stargazers_count":500,"open_issues_count":4,"forks_count":26,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-28T17:03:12.149Z","etag":null,"topics":["composer","conflict","dependency","executable","isolation","tool"],"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/bamarni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2016-05-02T08:27:20.000Z","updated_at":"2025-04-26T12:55:20.000Z","dependencies_parsed_at":"2024-06-18T10:52:33.773Z","dependency_job_id":"f7f87c88-e7a7-48db-95a6-461adbd8efa8","html_url":"https://github.com/bamarni/composer-bin-plugin","commit_stats":{"total_commits":131,"total_committers":18,"mean_commits":7.277777777777778,"dds":0.5572519083969465,"last_synced_commit":"a633e8b06d8bc44d7ee70a8cbebaa6ab1084c31c"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamarni%2Fcomposer-bin-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamarni%2Fcomposer-bin-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamarni%2Fcomposer-bin-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamarni%2Fcomposer-bin-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bamarni","download_url":"https://codeload.github.com/bamarni/composer-bin-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254029002,"owners_count":22002283,"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":["composer","conflict","dependency","executable","isolation","tool"],"created_at":"2024-08-04T01:00:27.105Z","updated_at":"2026-01-30T01:26:46.524Z","avatar_url":"https://github.com/bamarni.png","language":"PHP","readme":"# Composer bin plugin — Isolate your bin dependencies\n\n[![Package version](http://img.shields.io/packagist/v/bamarni/composer-bin-plugin.svg?style=flat-square)](https://packagist.org/packages/bamarni/composer-bin-plugin)\n[![License](https://img.shields.io/badge/license-MIT-red.svg?style=flat-square)](LICENSE)\n\n\n## Table of Contents\n\n1. [Why? A hard problem with a simple solution.](#why-a-hard-problem-with-a-simple-solution)\n1. [Usage; How does this plugin work?](#usage-how-does-this-plugin-work)\n1. [Installation](#installation)\n1. [Configuration](#configuration)\n   1. [Bin links (`bin-links`)](#bin-links-bin-links)\n   1. [Target directory (`target-directory`)](#target-directory-target-directory)\n   1. [Forward command (`forward-command`)](#forward-command-forward-command)\n1. [Tips \u0026 Tricks](#tips--tricks)\n    1. [Auto-installation](#auto-installation)\n    1. [Reduce clutter](#reduce-clutter)\n    1. [GitHub Actions integration](#github-actions-integration)\n1. [Related plugins](#related-plugins)\n1. [Backward Compatibility Promise](#backward-compatibility-promise)\n1. [Contributing](#contributing)\n\n\n## Why? A hard problem with a simple solution.\n\nWhen managing your dependencies with [Composer][composer], your dependencies are\nflattened with compatible versions, or when not possible, result in conflict\nerrors.\n\nThere is cases however when adding a tool as a dependency, for example [PHPStan][phpstan]*\nor [Rector][rector] could have undesired effects due to the dependencies they\nare bringing. For example if phpstan depends on `nikic/php-parser` 4.x and rector\n3.x, you cannot install both tools at the same time (despite the fact that from\na usage perspective, they do not need to be compatible). Another example, maybe\nyou can no longer add a non-dev dependency because a dependency brought by PHPStan\nis not compatible with it.\n\nThere is nothing special or exceptional about this problem: this is how dependencies\nwork in PHP with Composer. It is however annoying in the case highlighted above,\nbecause the conflicts should not be: it is a limitation of Composer because it\ncannot infer how you are using each dependency.\n\nOne way to solve the problem above, is to install those dependencies in a \ndifferent `composer.json` file. It comes with its caveats, for example if you\nwere to do that with [PHPUnit][phpunit], you may find yourself in the scenario\nwhere PHPUnit will not be able to execute your tests because your code is not\ncompatible with it and Composer is not able to tell since the PHPUnit dependency\nsits alone in its own `composer.json`. It is the very problem Composer aim to\nsolve. As a rule of thumb, **you should limit this approach to tools which do not\nautoload your code.**\n\nHowever, managing several `composer.json` kind be a bit annoying. This plugin\naims at helping you doing this.\n\n\n*: You will in practice not have this problem with PHPStan as the Composer package\n`phpstan/phpstan` is shipping a scoped PHAR (scoped via [PHP-Scoper][php-scoper])\nwhich provides not only a package with no dependencies but as well that has no\nrisk of conflicting/crash when autoloading your code.\n\n\n## Usage; How does this plugin work?\n\nThis plugin registers a `bin \u003cbin-namespace-name\u003e` command that allows you to\ninteract with the `vendor-bin/\u003cbin-namespace-name\u003e/composer.json`* file.\n\nFor example:\n\n```bash\n$ composer bin php-cs-fixer require --dev friendsofphp/php-cs-fixer\n\n# Equivalent to manually doing:\n$ mkdir vendor-bin/php-cs-fixer\n$ cd vendor-bin/php-cs-fixer \u0026\u0026 composer require --dev friendsofphp/php-cs-fixer\n```\n\nYou also have a special `all` namespace to interact with all the bin namespaces:\n\n```bash\n# Runs \"composer update\" for each bin namespace\n$ composer bin all update\n```\n\n\n## Installation\n\n```bash\n$ composer require --dev bamarni/composer-bin-plugin\n```\n\n\n## Configuration\n\n```json\n{\n    ...\n    \"extra\": {\n        \"bamarni-bin\": {\n            \"bin-links\": false,\n            \"target-directory\": \"vendor-bin\",\n            \"forward-command\": true\n        }\n    }\n}\n```\n\n\n### Bin links (`bin-links`)\n\nIn 1.x: enabled by default.\nIn 2.x: disabled by default.\n\nWhen installing a Composer package, Composer may add \"bin links\" to a bin\ndirectory. For example, by default when installing `phpunit/phpunit`, it will\nadd a symlink `vendor/bin/phpunit` pointing to the PHPUnit script somewhere in\n`vendor/phpunit/phpunit`.\n\nIn 1.x, BamarniBinPlugin behaves the same way for \"bin dependencies\", i.e. when\nexecuting `composer bin php-cs-fixer require --dev friendsofphp/php-cs-fixer`,\nit will add a bin link `vendor/bin/php-cs-fixer -\u003e vendor-bin/php-cs-fixer/vendor/friendsofphp/php-cs-fixer`.\n\nThis is however a bit tricky and cannot provide consistent behaviour. For example\nwhen installing several packages with the same bin, (e.g. with the case above installing\nanother tool that uses PHP-CS-Fixer as a dependency in another bin namespace),\nthe symlink may or may not be overridden, or not created at all. Since it is not\npossible to control this behaviour, neither provide an intuitive or deterministic\napproach, it is recommended to set this setting to `false` which will be the\ndefault in 2.x.\n\nIt does mean that instead of using `vendor/bin/php-cs-fixer` you will have to\nuse `vendor-bin/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/path/tophp-cs-fixer`\n(in which case setting an alias via a Composer script or something is recommended).\n\n\n### Target directory (`target-directory`)\n\nDefaults to `vendor-bin`, can be overridden to anything you wish.\n\n\n### Forward command (`forward-command`)\n\nDisabled by default in 1.x, will be enabled by default in 2.x. If this mode is\nenabled, all your `composer install` and `composer update` commands are forwarded\nto _all_ bin directories.\n\nThis is a replacement for the tasks shown in section [Auto-installation](#auto-installation).\n\n\n## Tips \u0026 Tricks\n\n### Auto-installation\n\nYou can easily forward a command upon a `composer install` to forward the install\nto all (in which case having `extra.bamarni-bin.forward_command = true` is more\nadapted) or a specific of bin namespace:\n\n```json\n{\n    \"scripts\": {\n        \"bin\": \"echo 'bin not installed'\",\n        \"post-install-cmd\": [\"@composer bin php-cs-fixer install --ansi\"]\n    }\n}\n```\n\nYou can customise this as you wish leveraging the [Composer script events][composer-script-events]).\n\n\n### Reduce clutter\n\nYou can add the following line to your `.gitignore` file in order to avoid\ncommitting dependencies of your tools.\n\n```.gitignore\n# .gitignore\n/vendor-bin/**/vendor/\n```\n\nUpdating each tool can create many not legible changes in `composer.lock` files.\nYou can use a `.gitattributes` file in order to inform git that it shouldn't show\ndiffs of `composer.lock` files.\n\n```.gitattributes\n# .gitattributes\n/vendor-bin/**/composer.lock binary\n```\n\n### GitHub Actions integration\n\nThere is currently no way to leverage `ramsey/composer-install` to install all\nnamespace bins. However it is unlikely you need this in the CI and not locally,\nin which case [forwarding the command](#forward-command-forward-command) should\nbe good enough.\n\nIf you still need to install specific bin namespaces, you can do it by setting\nthe `working-directory`:\n\n```yaml\n#...\n    -   name: \"Install PHP-CS-Fixer Composer dependencies\"\n        uses: \"ramsey/composer-install@v2\"\n        with:\n            working-directory: \"vendor-bin/php-cs-fixer\"\n```\n\n\n\n## Related plugins\n\n* [theofidry/composer-inheritance-plugin][theofidry-composer-inheritance-plugin]: Opinionated version\n  of [Wikimedia composer-merge-plugin][wikimedia-composer-merge-plugin] to work in pair with this plugin.\n\n\n## Backward Compatibility Promise\n\nThe backward compatibility promise only applies to the following API:\n\n- The commands registered by the plugin\n- The behaviour of the commands (but not their logging/output)\n- The Composer configuration\n\nThe plugin implementation is considered to be strictly internal and its code may\nchange at any time in a non back-ward compatible way.\n\n\n## Contributing\n\nA makefile is available to help out:\n\n```bash\n$ make # Runs all checks\n$ make help # List all available commands\n```\n\n**Note:** you do need to install [phive][phive] first.\n\n\n[composer]: https://getcomposer.org\n[composer-script-events]: https://getcomposer.org/doc/articles/scripts.md#command-events\n[phive]: https://phar.io/\n[php-scoper]: https://github.com/humbug/php-scoper\n[phpstan]: https://phpstan.org/\n[phpunit]: https://github.com/sebastianbergmann/phpunit\n[rector]: https://github.com/rectorphp/rector\n[symfony-bc-policy]: https://symfony.com/doc/current/contributing/code/bc.html\n[theofidry-composer-inheritance-plugin]: https://github.com/theofidry/composer-inheritance-plugin\n[wikimedia-composer-merge-plugin]: https://github.com/wikimedia/composer-merge-plugin\n","funding_links":[],"categories":["PHP","Plugins"],"sub_categories":["Support"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamarni%2Fcomposer-bin-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbamarni%2Fcomposer-bin-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamarni%2Fcomposer-bin-plugin/lists"}