Composer 1 (deprecated) and Composer 2 are readily available on our Web Premium, Web Business, and Cloud plans, as they come pre-installed. However, you may encounter some package installation, permission, or memory issues while using either of them. Follow the steps below to identify and resolve these issues:
You Should Upgrade to Composer 2 Message
Starting with PHP version 8.0, Composer 1 is no longer supported. If you attempt to install packages using Composer 1 with PHP 8.0 or higher, you'll encounter an error message prompting you to upgrade to Composer 2:
To address this, use the
composer2 command instead of the deprecated
composer command. For instance, to install the gumlet/php-image-resize package, use:
composer2 require gumlet/php-image-resize
The command may be intepreted automatically to try and install the packge using version 2.0, if available. Otherwise, you can try with the composer2 command instead, as mentioned.
If the command or package you need is only available on Composer 1, you can temporarily lower your PHP version. However, for security reasons, it is recommended to update your scripts or code to work with the latest PHP version.
The installation of Composer 1 and Composer 2 is global accross our servers, meaning that the available versions are fixed. Attempting to update Composer using the following commands:
composer self-update or
composer self-update --2
Or other commands requiring higher permissions may result in a "Permission denied" error:
To fix this, you will need to download and install the Composer locally for each project that requires it. Follow this guide to complete the process: Command-line installation.
Once installed, you'll find a new composer.phar file on the installation path:
You can now run any command, including
self-update, by executing locally. Use this format:
For example, to update Composer locally, enter:
./composer.phar self-update --2
If you encounter a Memory exhausted error after running Composer commands, it indicates that your project has exceeded the available memory limits of your hosting plan.
To address this, try running Composer with an unlimited memory flag. Use this format for global Composer:
php -d memory_limit=-1 /usr/local/bin/composer [COMMAND]
Or this format for a local Composer installation:
php -d memory_limit=-1 composer.phar [COMMAND]