问题
When triing to install FOSuserbundle with composer I got the following message in the Terminal:
"PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 79 bytes) in phar:///Users/myname/MyWebSite/composer.phar/src/Composer/ DependencyResolver/Solver.php on line 177"
How can I fix it?
EDIT / FURTHER INFORMATION
In Terminal typing: php -r "echo ini_get('memory_limit').PHP_EOL;"
get me the following: 128M
while php.ini (App/MAMP/conf/php5.4.4/php.ini) has the following line: memory_limit = 32M
why different value? how can I change the value so that composer can install the bundle?
I tried the following in terminal but got an error: php -d memory_limit=512M composer.phar/src/Composer/DependencyResolver/Solver.php
error ==> Could not open input file: composer.phar/src/Composer/DependencyResolver/Solver.php
回答1:
I've solved this in the past by using simply:
php -d memory_limit=1G /usr/local/bin/composer update --prefer-dist --no-dev
Where the no-dev may help reduce the memory footprint too - certainly speed.
回答2:
Composer should be run with at least 1 GB of allowed and available memory. If your machine has less memory physically installed, you should consider upgrading or using a different machine - otherwise the process will start swapping and taking huge amounts of time, so something that should be done in less than a minute will take days.
If you are unable to raise the memory limit for PHP, you are out of luck unfortunately. Composer needs some huge data structures when updating.
来源:https://stackoverflow.com/questions/28069382/php-fatal-error-momory-size-exhausted-when-using-composer-to-install-user-bundl