Home >Backend Development >PHP Tutorial >How to Fix Composer's 'Allowed memory size... exhausted' Error During Package Installation?

How to Fix Composer's 'Allowed memory size... exhausted' Error During Package Installation?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-13 08:30:15973browse

How to Fix Composer's

Troubleshooting Composer Require Out of Memory Error

Attempting to install HWIOAuthBundle in your project using composer require results in an "Allowed memory size... exhausted" error. Despite increasing memory_limit to 2G in the php.ini file, the error persists.

To resolve this issue, you may try the following:

  • Adjust memory_limit in php.ini:

    • Check the current memory limit using php -r "echo ini_get('memory_limit').PHP_EOL;"
    • Increase the limit in the php.ini file (e.g., /etc/php5/cli/php.ini for Debian systems):

      ; Use -1 for unlimited or define an explicit value like 2G
      memory_limit = -1
  • Use a command-line argument:

    php -d memory_limit=-1 composer.phar require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
  • Check loaded php.ini files:

    php --ini
  • Quick fix options:

    php composer.phar COMPOSER_MEMORY_LIMIT=-1 require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle

    or

    COMPOSER_MEMORY_LIMIT=-1 composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle

The above is the detailed content of How to Fix Composer's 'Allowed memory size... exhausted' Error During Package Installation?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn