From a294af3f16ce3505368a381a4c51453157dcb629 Mon Sep 17 00:00:00 2001 From: Rens Admiraal Date: Sun, 11 Sep 2016 14:13:54 +0200 Subject: [PATCH 1/2] Allow setting default transport strategy for path repositories This change allows setting COMPOSER_MIRROR_PATH_REPOS to 1 in the environment to set the default strategy to 'mirror'. This allows using 'mirror' during deployments while still symlinking on a development machine. The default is still overwritten by the options on the repository configuration. --- doc/03-cli.md | 6 ++++++ src/Composer/Downloader/PathDownloader.php | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/doc/03-cli.md b/doc/03-cli.md index eaffea3b1..340d2f299 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -868,4 +868,10 @@ If set to 1, this env disables the warning about running commands as root/super It also disables automatic clearing of sudo sessions, so you should really only set this if you use Composer as super user at all times like in docker containers. +### COMPOSER_MIRROR_PATH_REPOS + +If set to 1, this env changes the default path repository strategy to `mirror` instead +of `symlink`. As it is the default strategy being set it can still be overwritten by +repository options. + ← [Libraries](02-libraries.md) | [Schema](04-schema.md) → diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index bc18f88d8..cf0cb4068 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -59,6 +59,11 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter $currentStrategy = self::STRATEGY_SYMLINK; $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR); + $mirrorPathRepos = getenv('COMPOSER_MIRROR_PATH_REPOS'); + if (true === (bool)$mirrorPathRepos) { + $currentStrategy = self::STRATEGY_MIRROR; + } + if (true === $transportOptions['symlink']) { $currentStrategy = self::STRATEGY_SYMLINK; $allowedStrategies = array(self::STRATEGY_SYMLINK); From 0c4cae056f6264c9dd882a46d42512b0e9d8419e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 29 Sep 2016 08:40:03 +0200 Subject: [PATCH 2/2] Simplify code --- src/Composer/Downloader/PathDownloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index cf0cb4068..6505d1f02 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -60,7 +60,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR); $mirrorPathRepos = getenv('COMPOSER_MIRROR_PATH_REPOS'); - if (true === (bool)$mirrorPathRepos) { + if ($mirrorPathRepos) { $currentStrategy = self::STRATEGY_MIRROR; }