All Projects → bamarni → Composer Bin Plugin

bamarni / Composer Bin Plugin

Licence: mit
No conflicts for your bin dependencies

Projects that are alternatives of or similar to Composer Bin Plugin

Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+882.93%)
Mutual labels:  composer, tool
Rex
Your RegEx companion.
Stars: ✭ 283 (-1.39%)
Mutual labels:  tool
Picocli
Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
Stars: ✭ 3,286 (+1044.95%)
Mutual labels:  executable
Mozart
Developers tool for WordPress plugins: Wraps all your projects dependencies in your own namespace, in order to prevent conflicts with other plugins loading the same dependencies in different versions.
Stars: ✭ 277 (-3.48%)
Mutual labels:  composer
Catch Admin
CatchAdmin是一款基于thinkphp6 和 element admin 开发的后台管理系统,基于 ServiceProvider,系统模块完全接耦。随时卸载安装模块。提供了完整的权限和数据权限等功能,大量内置的开发工具提升你的开发体验。官网地址:
Stars: ✭ 264 (-8.01%)
Mutual labels:  composer
Repman
Repman - PHP Repository Manager: packagist proxy and host for private packages
Stars: ✭ 277 (-3.48%)
Mutual labels:  composer
Acf Pro Installer
A composer install helper for Advanced Custom Fields PRO
Stars: ✭ 265 (-7.67%)
Mutual labels:  composer
Plgo
easily create postgresql extensions in golang; moved to gitlab.com/microo8/plgo
Stars: ✭ 286 (-0.35%)
Mutual labels:  tool
Go command tutorial
Golang command tutorial in Chinese.
Stars: ✭ 3,155 (+999.3%)
Mutual labels:  tool
Laravel Translator
An Eloquent translator for Laravel
Stars: ✭ 275 (-4.18%)
Mutual labels:  composer
Onefetch
Git repository summary on your terminal
Stars: ✭ 3,680 (+1182.23%)
Mutual labels:  tool
Golds
An experimental Go local docs server/generator and code reader implemented with some fresh ideas.
Stars: ✭ 269 (-6.27%)
Mutual labels:  tool
Teip
Select partial standard input and replace with the result of another command efficiently
Stars: ✭ 280 (-2.44%)
Mutual labels:  tool
Canvas Designer
Collaborative, extendable, JavaScript Canvas2D drawing tool, supports dozens of builtin tools, as well as generates JavaScript code for 2D animations.
Stars: ✭ 268 (-6.62%)
Mutual labels:  tool
Isolate
Lightweight image browser
Stars: ✭ 284 (-1.05%)
Mutual labels:  tool
Php Aws Ses
PHP classes that interfaces Amazon Simple Email Service
Stars: ✭ 263 (-8.36%)
Mutual labels:  composer
Svgson
Transform svg files to json notation
Stars: ✭ 271 (-5.57%)
Mutual labels:  tool
Concuerror
Concuerror is a stateless model checking tool for Erlang programs.
Stars: ✭ 277 (-3.48%)
Mutual labels:  tool
Logistics
PHP 多接口获取快递物流信息包
Stars: ✭ 287 (+0%)
Mutual labels:  composer
Sourcedocs
Generate Markdown documentation from source code
Stars: ✭ 286 (-0.35%)
Mutual labels:  executable

Composer bin plugin — Isolate your bin dependencies

Package version Build Status License

Table of Contents

  1. Why?
  2. How does this plugin work?
  3. Installation
  4. Usage
    1. Example
    2. The all bin namespace
    3. What happens when symlink conflicts?
  5. Tips
    1. Auto-installation
    2. Disable links
    3. Change directory
    4. Reduce clutter
  6. Related plugins

Why?

In PHP, with Composer, your dependencies are flattened, which might result in conflicts. Most of the time those conflicts are legitimate and should be properly resolved. However you may have dev tools that you want to manage via Composer for convenience, but should not influence your project dependencies or for which conflicts don't make sense. For example: EtsyPhan and PhpMetrics. Installing one of those static analysis tools should not change your application dependencies, neither should it be a problem to install both of them at the same time.

How does this plugin work?

It allows you to install your bin vendors in isolated locations, and still link them to your bin-dir (if you want to).

This is done by registering a bin command, which can be used to run Composer commands inside a namespace.

Installation

# Globally
$ composer global require bamarni/composer-bin-plugin

# In your project
$ composer require --dev bamarni/composer-bin-plugin

Usage

$ composer bin [namespace] [composer_command]
$ composer global bin [namespace] [composer_command]

Example

Let's install Behat and PhpSpec inside a bdd bin namespace, EtsyPhan in etsy-phan and PhpMetrics in phpmetrics:

$ composer bin bdd require behat/behat phpspec/phpspec
$ composer bin etsy-phan require etsy/phan
$ composer bin phpmetrics require phpmetrics/phpmetrics

This command creates the following directory structure :

.
├── composer.json
├── composer.lock
├── vendor/
│   └── bin
│       ├── behat -> ../../vendor-bin/bdd/vendor/behat/behat/bin/behat
│       ├── phpspec -> ../../vendor-bin/bdd/vendor/phpspec/phpspec/bin/phpspec
│       ├── phan -> ../../vendor-bin/etsy-phan/vendor/etsy/phan/phan
│       └── phpmetrics -> ../../vendor-bin/phpmetrics/vendor/phpmetrics/phpmetrics/bin/phpmetrics
└── vendor-bin/
    └── bdd
    │   ├── composer.json
    │   ├── composer.lock
    │   └── vendor/
    │       ├── behat/
    │       ├── phpspec/
    │       └── ...
    └── etsy-phan
    │   ├── composer.json
    │   ├── composer.lock
    │   └── vendor/
    │       ├── etsy/
    │       └── ...
    └── phpmetrics
        ├── composer.json
        ├── composer.lock
        └── vendor/
            ├── phpmetrics/
            └── ...

You can continue to run vendor/bin/behat, vendor/bin/phpspec and co. as before but they will be properly isolated. Also, composer.json and composer.lock files in each namespace will allow you to take advantage of automated dependency management as normally provided by Composer.

The all bin namespace

The all bin namespace has a special meaning. It runs a command for all existing bin namespaces. For instance, the following command would update all your bins :

$ composer bin all update
Changed current directory to vendor-bin/phpspec
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Changed current directory to vendor-bin/phpunit
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files

What happens when symlink conflicts?

If we take the case described in the example section, there might be more binaries linked due to the dependencies. For example PhpMetrics depends on Nikic PHP-Parser and as such you will also have php-parse in .vendor/bin/:

.
├── composer.json
├── composer.lock
├── vendor/
│   └── bin
│       ├── phpmetrics -> ../../vendor-bin/phpmetrics/vendor/phpmetrics/phpmetrics/bin/phpmetrics
│       └── php-parse -> ../../vendor-bin/phpmetrics/vendor/nikic/PHP-Parser/bin/php-parsee
└── vendor-bin/
    └── phpmetrics
        ├── composer.json
        ├── composer.lock
        └── vendor/
            ├── phpmetrics/
            ├── nikic/
            └── ...

But what happens if another bin-namespace has a dependency using Nikic PHP-Parser? In that situation symlinks would collides and are not created (only the colliding ones).

Tips

Auto-installation

For convenience, you can add the following script in your composer.json :

{
    "scripts": {
        "bin": "echo 'bin not installed'",
        "post-install-cmd": ["@composer bin all install --ansi"],
        "post-update-cmd": ["@composer bin all update --ansi"]
    }
}

This makes sure all your bins are installed during composer install and updated during composer update.

Disable links

By default, binaries of the sub namespaces are linked to the root one like described in example. If you wish to disable that behaviour, you can do so by adding a little setting in the extra config:

{
    "extra": {
        "bamarni-bin": {
            "bin-links": false
        }
    }
}

Change directory

By default, the packages are looked for in the vendor-bin directory. The location can be changed using target-directory value in the extra config:

{
    "extra": {
        "bamarni-bin": {
            "target-directory": "ci/vendor"
        }
    }
}

Reduce clutter

You can add following line to your .gitignore file in order to avoid committing dependencies of your tools.

/vendor-bin/**/vendor

Updating each tool can create many not legible changes in composer.lock files. You can use .gitattributes file in order to inform git that it shouldn't show diffs of composer.lock files.

vendor-bin/**/composer.lock binary

Related plugins

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].