Composer running out of memory on every project, Mac OS X

前端 未结 9 1910
遇见更好的自我
遇见更好的自我 2020-12-01 14:50

I attempted to install aws/aws-sdk-php yesterday on one of my Laravel 4 projects using Composer, I cannot remember exactly the chain of events but it did not in

相关标签:
9条回答
  • 2020-12-01 15:30

    If you're having 8 GB of Ram or more, then you can surely increase the PHP memory_limit to 1 GB or else to 512MB. On your Mac open terminal-

    1. Find the PHP memory limit config file.
    php --ini
    
    1. Edit the php-memory-limits.ini file.
    nano /usr/local/etc/php/7.4/conf.d/php-memory-limits.ini
    
    1. Increase Memory limit to 1 GB
    memory_limit = 1G
    
    1. Verify if the Memory limit increased or not.
    php -r "echo ini_get('memory_limit').PHP_EOL;"
    
    1. Restart PHP service.
    brew services restart php
    

    And done. Increasing the memory limit also reduces a little bit of composer update completion time, which is good.

    If you wanna speed up composer update time. Try installing the popular - Prestissimo package.

    0 讨论(0)
  • 2020-12-01 15:31

    Easy, type this commands:

    rm -rf vendor/

    rm -rf composer.lock

    php composer install --prefer-dist

    Should work for low memory machines or others memory problems

    0 讨论(0)
  • 2020-12-01 15:37

    I ran into this too but I use brew.

    composer --version
    brew info composer
    brew upgrade composer
    ...
    ==> Upgrading 1 outdated package:
    composer 1.9.0 -> 1.9.2
    ==> Upgrading composer 
    ...
    

    which still did not fix my composer require drupal/environment_indicator

    Using the php memory limit mentioned by others fixed this finally.

    php -d memory_limit=-1 `which composer` require drupal/environment_indicator
    
    0 讨论(0)
提交回复
热议问题