Composer Update failed — out of memory

后端 未结 25 2560
再見小時候
再見小時候 2020-12-01 00:40

I got this error when running composer.phar update on my VM:

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried t

相关标签:
25条回答
  • 2020-12-01 01:21

    It worked for me!

    Download the zip 64-bit version of your PHP from this link: https://windows.php.net/download/

    Now extract it to C:\PHP-74\ and rename the php.ini-development to php.ini

    Now open this php.ini and uncomment the following by removing ; (semicolon).

    extension_dir = "ext"
    extension=bz2
    extension=curl
    extension=fileinfo
    extension=gd2
    extension=gettext
    extension=mbstring
    extension=exif      ; Must be after mbstring as it depends on it
    extension=mysqli
    extension=openssl
    extension=pdo_sqlite
    

    In my scenario these extensions are required you can compare your old php.ini file of xampp or wamp resolve this one. Now save the file and run the following command.

    "C:\PHP-74\php.exe" -d memory_limit=-1 "C:\ProgramData\ComposerSetup\bin\composer.phar" update
    
    0 讨论(0)
  • 2020-12-01 01:24

    Try this one

    COMPOSER_MEMORY_LIMIT=-1 composer require [package name]
    
    0 讨论(0)
  • 2020-12-01 01:25

    It's a memory problem, not a storage issue. You are reaching your PHP memory limit.

    Edit /etc/php.ini and increase the memory limit ( memory_limit = 128M replace with memory_limit = 256M )

    I would suggest you look for the reason composer is using so much memory , and find ways to cut your PHP memory usage :

    1. Upgrade to PHP56 if you haven't already
    2. Install Zend Opcache ( shares PHP memory between different instances )
    3. Uninstall any and all unused PECL extensions

    This is the issue you are having : https://github.com/composer/composer/issues/1898

    0 讨论(0)
  • 2020-12-01 01:25

    Try increase the memory_limit value in your active php.ini file.

    ; Maximum amount of memory a script may consume (128MB)
    ; http://php.net/memory-limit
    memory_limit = 512M
    

    For example.

    0 讨论(0)
  • 2020-12-01 01:26
    php -d memory_limit=-1 /usr/local/bin/composer install
    

    This command work for me.

    0 讨论(0)
  • 2020-12-01 01:29

    Nothing worked for me except putting memory_limit = -1 in php.ini file.

    0 讨论(0)
提交回复
热议问题