From 882b82d542b45435bae1d95b33e225427950c59c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 4 Jan 2018 10:49:41 +0100 Subject: [PATCH] Add COMPOSER_MEMORY_LIMIT env var to force a given memory_limit, fixes #6931 --- bin/composer | 4 ++++ doc/03-cli.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/bin/composer b/bin/composer index 88566e170..0664e04ce 100755 --- a/bin/composer +++ b/bin/composer @@ -45,6 +45,10 @@ if (function_exists('ini_set')) { if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) { @ini_set('memory_limit', '1536M'); } + // Set user defined memory limit + if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) { + @ini_set('memory_limit', $memoryLimit); + } unset($memoryInBytes, $memoryLimit); } diff --git a/doc/03-cli.md b/doc/03-cli.md index 4880d5406..04ae1d0ae 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -909,6 +909,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_MEMORY_LIMIT + +If set, the value is used as php's memory_limit. + ### COMPOSER_MIRROR_PATH_REPOS If set to 1, this env changes the default path repository strategy to `mirror` instead