While using composer, you might face errors, we gathered solutions to the most common issues:
Issue 1 - Permission denied
In case you want to use commands like
composer self-update and get this error:
You do need to download and install the composer locally. A step-by-step guide can be found here: Command-line installation. Once that’s done, a new file composer.phar will appear:
Now you will be able to run any command you’ve used before, as well as use commands like
self-update. Keep in mind that local composer commands should look like this:
You will need to install a local Composer for each of your projects
Issue 2 - Packages will not be available. You should upgrade to Composer 2 error
In case you are using PHP 8.0, any old composer commands might not work. Instead, you need to use composer2. For example, a command for installing gumlet/php-image-resize should look like this:
composer2 require gumlet/php-image-resize. As an alternative, you can lower your PHP version.
Issue 3 - Memory exhausted
If after running composer commands you see an error about Memory exhausted - it’s a good indication that limits were hit.
To solve the Memory exhausted issue, you can try running composer with an Unlimited memory flag like this:
php -d memory_limit=-1 /usr/local/bin/composer [COMMAND] or
php -d memory_limit=-1 composer.phar [COMMAND] when using a local composer. If that doesn’t help, you can upgrade your hosting plan. Alternatively, you can run demanding commands like composer update on your local machine and upload your project to Hostinger.