How to resolve PHP memory limit errors on OSX

2020. Mar. 20. · 1 min read
You can easily run into a PHP memory limit problem eg. by using Composer to get the code of Drupal (or a Drupal module).

A one-time, quick solution is to increase the limit with a command-line argument. So instead of

composer require drupal/webform

you write

php -d memory_limit=-1 composer require drupal/webform

If you don’t want to prefix your commands every time you have to update the related php.ini file.

In case of using the default PHP comes with OSX you have to look for

Machintos HD/etc/php.ini.default

Duplicate this file as php.ini and in that update the memory_limit eg. like this

memory_limit = 2G

As Composer may use even 1.5GB of memory it is good to set the limit as above. Be careful to not write 2GB, just 2G because the first won’t work!

If you want to provide unlimited memory, you can write

memory_limit = -1