diff --git a/doc/articles/scripts.md b/doc/articles/scripts.md index f394f28e9..9b350c614 100644 --- a/doc/articles/scripts.md +++ b/doc/articles/scripts.md @@ -150,6 +150,8 @@ class MyClass } ``` +**Note:** During composer install / update, a `COMPOSER_DEV_MODE` php environment variable is set. If composer install / update was run with the `--no-dev option`, this variable will be set to 0, otherwise it will be set to 1. This exposes the mode in which the install / update was run, to any post-install / update commands. + ## Event classes When an event is fired, your PHP callback receives as first argument a diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 49e82f06c..b1ac40834 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -292,6 +292,9 @@ class Installer } if ($this->runScripts) { + $devMode = (int) $this->devMode; + putenv("COMPOSER_DEV_MODE=$devMode"); + // dispatch post event $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD; $this->eventDispatcher->dispatchScript($eventName, $this->devMode);