vever001/composer-installers-dir

There is no license information available for the latest version (dev-master) of this package.

Small composer plugin using composer/installers that allows you to add an additional directory to package destinations.

dev-master 2019-08-02 19:44 UTC

This package is auto-updated.

Last update: 2024-04-29 04:09:32 UTC


README

The composer-installers-dir is a small composer plugin that allows you to specify a directory where all packages handled by composer/installers will be downloaded to.

Composer supports overriding the vendor location using vendor-dir out of the box.
This is not the case for packages using composer/installers.
This project allows you to define similarly an installer-dir in the extra section of your composer.json.

To install it:

composer require vever001/composer-installers-dir

This is useful if you have a composer project and you want to build it to another folder (e.g: for production release). Here's an example to build the whole project in a dist folder for production release:

DIR="dist"
composer config vendor-dir "$DIR/vendor"
composer config extra.installer-dir "$DIR"
composer install --no-dev
composer config --unset extra.installer-dir
composer config --unset vendor-dir
cp composer.json composer.lock $DIR
composer dump-autoload --working-dir="$DIR" --no-dev --optimize

Which will:

  • Add the following in the composer.json
      "extra": {
        ...
        "installer-dir": "dist"
      },
      "config": {
        ...
        "vendor-dir": "dist/vendor"
      }
    
  • Build the project to the dist folder (with --no-dev)
  • Revert the changes to the composer.json
  • Copy composer.json and composer.lock to the dist folder
  • Update the autoloader in the dist folder to resolve paths