I recently moved to a Mac and one of the first things I did was install Homebrew, then setup all of my PHP projects, one of them being a Laravel project which uses Composer for dependencies.
Then I hit a snag telling my I had exhausted my allowed memory allocation in my php.ini file. Well, shit.
The exact message I got was:
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar/src/Composer/DependencyResolver/RuleWatchNode.php on line 40
Research seems to indicate this happens to a lot of people on Mac OS when using Laravel/Symfony. Numerous fixes have been pushed, but the issues still appears to exist for some (including myself).
I am using MAMP Pro for managing my local server stuff, so editing the php.ini file is a simple matter of going to:
Menu -> File -> Edit Template ->php version and finding the memory_size directive.
If you are using something else for your local server, you will have to read the documentation to find out where your php.ini file is to bump up the allowed memory it can use.
In my php.ini file I bumped up the memory allowed to 1024M just in-case. It feels like a dirty hack, but I couldn’t find any other solution to get Composer to install my dependencies. I’ve never had this issue on Windows before, I guess, Mac’s are just more greedy.
Another fix you can try if the prospect of editing your php.ini file seems a little too daunting is the following:
php -d memory_limit=-1 /usr/local/bin/composer update