Running Out of Memory with Composer During Deployments?
Ever had a deployment fail due to PHP Composer hitting a memory limit? It's a common issue, but thankfully, there's a quick fix. A customer recently reached out with this exact problem and we got them back up and running in minutes.
The Fix
To resolve memory issues, use the following command in your build pipeline:
COMPOSER_MEMORY_LIMIT=-1 composer install --no-progress --optimize-autoloader
This simple command got our customer's project deploying successfully. As they put it: "That's worked and it now deploys :)"
What It Does
COMPOSER_MEMORY_LIMIT=-1
: Sets an unlimited memory limit specifically for the Composer process.--no-progress
: Cleans up your deployment logs by hiding the progress bar.--optimize-autoloader
: A production-focused flag that optimizes the autoloader for better performance.
If you're facing Composer memory errors, give this command a try. It's a simple, effective solution to keep your deployments running smoothly.