I’ve got a Laravel based project that I’m updating to version 5.6. To do so I need to update some PHP packages with composer.
When I run ‘composer update’ after making the changes to composer.json, it just hangs - nothing else prints and the command does not complete.
So far ony my most recent run it’s been 20 mins and no response. Usually it takes under 1 minute, and gives feedback immediately.
I’ve had a similar problem very rarely before where there was not enough memory available and I had to create a swap file. I checked, and the swap file is still there and has 2+ GB of space free.
Any other suggestions?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
If your composer update command is hanging and taking unusually long to complete in your Laravel project, this can indeed be frustrating. Here are several strategies and checks you can perform to diagnose and possibly resolve the issue:
Ensure you are using the latest version of Composer, as updates often include performance improvements and bug fixes:
composer self-update
Even though you mentioned having sufficient swap space, it’s often beneficial to explicitly allow Composer to use more memory. This can be especially useful on systems where PHP’s memory limit is globally set to a conservative value:
COMPOSER_MEMORY_LIMIT=-1 composer update
Setting COMPOSER_MEMORY_LIMIT=-1 allows Composer to use unlimited memory. If you are concerned about potential out-of-memory problems, specify a large but finite amount like 2G or 4G.
Composer relies on external connections to fetch package information. A slow or unreliable network connection can cause Composer to hang:
ping packagist.org to check if there’s a network latency or packet loss issue.Composer has a diagnostic tool to check common errors:
composer diagnose
This command checks for potential issues with your Composer setup.
Running the update command with verbose output or profiling can provide more insight into where Composer might be hanging:
composer update --verbose
Or to see performance profiling:
composer update --profile
Sometimes, Composer plugins can interfere with the update process. Try running Composer without plugins:
composer update --no-plugins
If you have any custom scripts in your composer.json (e.g., scripts that run pre- or post-update), ensure these scripts are not causing a deadlock or waiting indefinitely for an external resource.
If the problem persists, consider updating packages one by one or in smaller groups to isolate the problematic dependency if any.
Look at tools like top or htop on Linux to see if Composer is actively using CPU or if it’s stuck waiting for I/O operations. This can give you a clue whether the process is actively working or merely hanging.
Sometimes, conflicts between packages can cause Composer to hang while solving dependencies. Try updating dependencies one at a time to isolate any conflicts:
composer require some/package
By following these steps, you should be able to better understand why composer update is hanging and hopefully resolve the issue. If the problem is particularly persistent, consider breaking down your composer.json to simpler forms and gradually build up to identify the problematic configuration or package.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.