Browse Source

Add COMPOSER_MEMORY_LIMIT env var to force a given memory_limit, fixes #6931

Jordi Boggiano 7 years ago
parent
commit
882b82d542
2 changed files with 8 additions and 0 deletions
  1. 4 0
      bin/composer
  2. 4 0
      doc/03-cli.md

+ 4 - 0
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);
 }
 

+ 4 - 0
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