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