Fix Composer Memory Error - PHP Fatal error: Allowed memory size of xx bytes exhausted



I got this error while installing a Laravel package today and got it fixed so easily.

The exact error was this:

PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors. 


To fix this, you can either increase the memory limit for php, or ignore the memory limit for this command at the time you run this. I opted for the second method as I wanted to do this just one time.

Just run the same command as below:

php -d memory_limit=-1 <composer-bin-path> require <package-name>
Ex:
php -d memory_limit=-1 /usr/local/bin/composer require kreait/laravel-firebase

You can find the path for composer by using the following command. which composer
vagrant@homestead:~/$ which composer
/usr/local/bin/composer


Hope this will help someone.

1 comments :

  1. Life is always beautiful when you be with the true person you love. For almost a year my lover had broke up with me and I was lonely and sad luckily I was directed to a very little kind and Great spell caster called Dr Ralph who helped me to bring back my lover to me and today I am happy together and very grateful for what you have done for me, He can also help you cast spell like Love spells, Money spells, business improvement spell, Cure for any kind of disease and sickness, lottery winning spell and many others. You can contact him on his Email him via Ralphspellsolution@gmail.com or whatsApp on. +2347037816417.

    ReplyDelete