itk-dev/composer-virtualenv

A simple virtual environment for composer

1.0.0 2018-06-09 10:40 UTC

This package is not auto-updated.

Last update: 2022-05-10 05:28:43 UTC


README

A simple virtual environment for composer.

Inspired by Python's virtualenv, this package adds a script for prepending vendor/bin to the PATH variable to make it easier to run commands installed via composer.

Background

Assume your composer.json contains

    "require-dev": {
        "phpunit/phpunit": "^6.5",
        "drush/drush": "^9.2"
    }

After running composer install you have to make sure to run vendor/bin/phpunit or vendor/bin/drush, respectively, to run the right command. If you just run phpunit you'll will run any globally installed version of phpunit (or get an error if phpunit is not installed).

Composer virtualenv, helps you run the right commands, i.e. the ones installed using composer, without having to (remember to) type vendor/bin/ every time.

Installation

composer require itk-dev/composer-virtualenv "^1.0"

Activating the virtual environment

To deactivate the virtual environment, run

source vendor/bin/activate

Note: It is important to source the script – it will not work if it is run.

This prepends the path vendor/bin to the PATH environment variable, and any command installed using composer will be run instead of any globally available command of the same name.

Deactivating the virtual environment

To deactivate the virtual environment and restore the PATH variable to its original value, run

deactivate