person with face in wall to fix composer timeout

Multiple Ways to Fix Composer Process Timeout Issues

TL;DR

The recommended method to fix Composer process timeout is on a per-script basis within the scripts object of your composer.json. This ensures that not all scripts are impacted by the change, and only applies to scripts which require no timeout.

"scripts": {
    "script-name": [
        "Composer\Config::disableProcessTimeout",
        "bash bin/long-running-script.sh"
    ]
}

Composer, the well-renowned PHP dependency manager, has become an indispensable tool for many software engineers. By acting as a centralized hub for handling packages and dependencies, Composer has greatly streamlined the development workflows. Furthermore, it provides a structured way for developers to organize their projects, ensuring consistent and repeatable builds.

However, while Composer offers numerous advantages, it isn’t without its occasional challenges. One such issue faced by developers involves the timeout of long-running scripts. Many projects, particularly those that are large or complex, include scripts that need a significant amount of time to execute. Due to Composer’s default settings, these scripts can sometimes timeout, causing interruptions and potential inconveniences.

Fix Composer Process Timeout

Thankfully, there are a few ways to fix these timeout issues. 😎

Using Composer’s Built-in Method:

You can leverage the built-in method disableProcessTimeout. This method, when incorporated into your script, can be used to disable Composer process timeout for that particular script’s execution. This is an ideal solution if you have only a few specific scripts that tend to take longer than others, and it ensure other scripts are not impacted by the change.

"scripts": {
    "script-name": [
        "Composer\Config::disableProcessTimeout",
        "bash bin/long-running-script.sh"
    ]
}

Adjusting the composer.json Configuration:

Composer allows you to directly set the timeout limit within the composer.json file. This can be achieved by modifying the config object and setting the process-timeout to your desired value (in seconds).

{
    "config": {
        "process-timeout": 600
    }
}

In the example above, the timeout has been set to 600 seconds (10 minutes). Adjust this value as per the requirements of your project.

Passing the COMPOSER_PROCESS_TIMEOUT Variable During Script Execution:

If you don’t want to make permanent changes to your configuration but need a temporary adjustment, you can pass the COMPOSER_PROCESS_TIMEOUT variable when executing your script. This method provides a quick way to override the default timeout value for a particular execution.

COMPOSER_PROCESS_TIMEOUT=600 composer run some-other-script

This command will execute some-command with a timeout of 600 seconds.

Setting the COMPOSER_PROCESS_TIMEOUT as an Environment Variable:

Another versatile, yet sometimes overbearing, method involves setting the COMPOSER_PROCESS_TIMEOUT as an environment variable on your machine. If you’re using a shell like zsh, you can add the following line to your .zshrc file:

# For the current shell window only
export COMPOSER_PROCESS_TIMEOUT=600 

# Append to your .zshrc config file
echo COMPOSER_PROCESS_TIMEOUT=600 >> ~/.zshrc

Once set, this will apply the specified timeout to all commands executed on your machine, unless overridden by one of the methods mentioned above.


While Composer tremendously eases the PHP development workflows, like all tools, it has its quirks. Timeouts with long-running scripts can be a hurdle, but by employing the methods detailed above, you can ensure smooth, uninterrupted script executions, and fix Composer process timeouts. Choose the method that best fits the needs of your project and workflow.