nfreear/composer-suggest

Composer plugin to install a custom group of suggested packages, based on keyword patterns. ' vi .env && composer install '

v1.2.0 2017-04-23 22:44 UTC

README

Build status — Travis-CI Latest Stable Version MIT License

composer-suggest

A Composer plugin to install a custom group of suggested packages, based on keyword patterns. (Caution)

Example composer.json:

{
    "suggest": {
      "a/b": "1.0; This package is for [LACE] only",
      "c/d": "2.1, This package is for JuxtaLearn and LACE.",
      "e/f": "3.2, This is just for [JXL].",
      "g/h": "1.0-beta; Experiment-A"
    }
}

Usage

  1. Set an environment variable containing a pattern/keywords in a .env file,

    echo 'NF_COMPOSER_SUGGEST="(EXP|LACE)"' > .env
  2. Require the plugin,

    composer require nfreear/composer-suggest
    
  3. Install as you would normally (verbose),

    composer -vvv install
    

Legacy

In Composer script mode, an example composer.json might contain:

{
    "suggest": {
      "a/b": "1.0; This package is for [LACE] only",
      "c/d": "2.1, This package is for JuxtaLearn and LACE.",
      "e/f": "3.2, This is just for [JXL].",
      "g/h": "1.0-beta; Experiment-A"
    },

    "scripts": {
      "dry-run-suggest": "\\Nfreear\\Composer\\Suggest::dryRun",
      "install-suggest": "\\Nfreear\\Composer\\Suggest::install",
      "install-lace": "./vendor/bin/suggest --dry LACE"
    }
}

Legacy usage:

>  composer -v install-lace

Legacy advanced usage:

>  composer -v dry-run-suggest "Ju?X(ta)?L"    # Packages suggested for 'Juxtalearn' & 'JXL'.
>  composer -v dry-run-suggest "Experiment-A"

Test

composer test

Caution

Use of the composer-suggest plugin implies that you probably won't commit composer.lock to version control. Various people say this is bad, and as a general rule they are probably correct.

Composer-suggest works well when all/most of the dependencies in require and suggest have precise version constraints (1.2.3) as opposed to loose ones (1.*, >= 1.5..). It is also useful during rapid development phases of a project. See it in use in the LACE/ OER Research Hub code, and Open Media Player code-base.

Caveat utilitor!

Developed for the LACE Evidence Hub, part of the Learning Analytics Community Exchange project.

Inspired by and based in part on the composer-merge-plugin – thank you!

License: MIT

© 2016 The Open University. (Institute of Educational Technology)