How to set an unlimited memory limit for Composer update

Composer is a dependency manager for PHP, which is used to manage the dependencies and libraries required by a PHP project. The “composer update” command is used to update the dependencies of a project to their latest versions.

When running the “composer update” command, PHP’s memory limit is set to a default value that is determined by the PHP configuration of the server. This default value may not be high enough for some projects, especially for those with a large number of dependencies or large dependency packages.

In such cases, the “composer update” command may fail with an error message related to memory limits.

COMPOSER_MEMORY_LIMIT=-1 composer update

To avoid this issue, you can set the PHP memory limit to unlimited before running the “composer update” command by using the “COMPOSER_MEMORY_LIMIT” environment variable.

When you set the value of this variable -1, you are telling PHP to use as much memory as it needs to run the command and it will not be limited by any pre-set value.

In summary, the command “COMPOSER_MEMORY_LIMIT=-1 composer update” sets the PHP memory limit to -1 (unlimited) before running the “composer update” command, this allow the composer update to run without any restriction of memory and resolve the issue related to memory limit.