Composer Memory Size Fatal Error – How to Fix

composercomposer-installfatal errormemory

I keep getting this error every time i run anything related to composer (install, update, require, etc.)

enter image description here

Ive tried almost every website or solution I could find to no avail. Can anyone tell me how to find that 2MB limit that's causing so many issues for my composer to function properly?

in my php.ini I've set the memory limit to 550MB but still doesn't work. I cant even install composer via the installer because it gives the same error.

Best Answer

First of all, download composer.phar to your Magento root folder:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

And then run composer commands like this:

php -d memory_limit=-1 composer.phar install