2017 © Pedro Peláez
 

composer-plugin isolate-composer

Isolates composer dependencies by prefixing namespace for all vendor code within a project

image

and/isolate-composer

Isolates composer dependencies by prefixing namespace for all vendor code within a project

  • Friday, June 8, 2018
  • by And
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Composer Dependency Isolation

What this plugin does, (*1)

This plugin prefixes all vendor namespaces with a chosen value. This includes all declared namespaces, use statements, fully qualified references, and most string values that reference the namespace., (*2)

All vendor code and composer autoload mappings are updated to reference the prefixed namespace., (*3)

What this plugin does not do, (*4)

It will not touch any code in your project. It only affects code in the vendor directory, and it only affects code referencing the affected namespaces. You must update all references in your code yourself if you apply this to an existing project., (*5)

Why would I want to use this?, (*6)

This plugin allows you to run two projects that utilize composer dependencies in the same runtime, without worrying about conflicting dependencies. The most common example is in a WordPress environment, where all plugins execute in the same runtime, and may rely on the same composer dependencies. Each project utilizing the plugin can't conflict with any other project unless the vendor code is not namespaced (in which case there aren't many options...)., (*7)

Usage

Using the plugin is straightforward. Install the plugin by requiring it in your project: composer require and/isolate-composer., (*8)

Configure the plugin by adding the following to your composer.json:, (*9)

"config" : {
    "isolate": {
      "prefix": "Your\\Prefix\\Here\\",
      "blacklist": [],
      "autorun": false,
      "require-dev": false,
      "replacements" : {}
    }
}

The only required value is the prefix., (*10)

After you have configured the plugin, run the isolation:, (*11)

composer isolate
composer dump

Your vendor code is now prefixed!, (*12)

Be sure to dump after you isolate, or your autoload mappings will be incorrect!, (*13)

Configuration

prefix, (*14)

This is the value that will be prepended to all vendor namespaces. It should be a valid namespace, and should be unique to your project. I recommend you don't use your main project namespace, or at least add \\Vendor to the end., (*15)

blacklist, (*16)

This is a list of packages you don't want to prefix. Matching packages will not be scanned for namespaces, but will still have code rewritten if it contains namespaces from other non-blacklisted packages., (*17)

autorun, (*18)

Setting this value to true automatically runs the isolation process before every dump., (*19)

require-dev, (*20)

By default, only require packages are scanned for namespaces, and require-dev packages are ignored (as above, they will still have code rewritten if they contain namespaces from other packages)., (*21)

Setting this value to true includes the require-dev packages in the scan, and any found namespaces will be prefixed., (*22)

replacements, (*23)

This is a place for manually fixing things in the vendor code that either were not detected and replaced, or replaced when they should not have been., (*24)

After each file has been parsed and rewritten, if there is an entry in the replacements list, it will do a string replace on the file., (*25)

String replacements should be idempotent, or things will break on multiple executions., (*26)

The syntax is:, (*27)

"replacements" : {
    "path/relative/to/vendor/root/file.php" : {
        "search" : "replace",
        "search" : "replace",
    },
    "path/relative/to/vendor/root/file.php" : {
            "search" : "replace",
            "search" : "replace",
        }
}

The Versions

08/06 2018

v1.1.x-dev

1.1.9999999.9999999-dev

Isolates composer dependencies by prefixing namespace for all vendor code within a project

  Sources   Download

MIT

The Requires

 

The Development Requires

08/06 2018

dev-master

9999999-dev

Isolates composer dependencies by prefixing namespace for all vendor code within a project

  Sources   Download

MIT

The Requires

 

The Development Requires

08/06 2018

1.1

1.1.0.0

Isolates composer dependencies by prefixing namespace for all vendor code within a project

  Sources   Download

MIT

The Requires

 

The Development Requires

22/02 2018

1.0

1.0.0.0

Isolates composer dependencies by prefixing namespace for all vendor code within a project

  Sources   Download

MIT

The Requires

 

The Development Requires