Jeff Geerling’s Blog: Make composer operations with Drupal way faster and easier on RAM

tl;dr: Run composer require zaporylie/composer-drupal-optimizations:^1.0 in your Drupal codebase to halve Composer’s RAM usage and make operations like require and update 3-4x faster.

A few weeks ago, I noticed Drupal VM’s PHP 5.6 automated test suite started failing on the step that runs composer require drupal/drush. (PSA: PHP 5.6 is officially dead. Don’t use it anymore. If you’re still using it, upgrade to a supported version ASAP!). This was the error message I was getting from Travis CI:

PHP Fatal error:  Allowed memory size of 2147483648 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/RuleWatchNode.php on line 40

I ran the test suite locally, and didn’t have the same issue (locally I have PHP’s CLI memory limit set to -1 so it never runs out of RAM unless I do insane-crazy things.