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
Release: 2024-12-13 08:30:15
Original
961 people have browsed it

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
      Copy after login
  • Use a command-line argument:

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

    php --ini
    Copy after login
  • Quick fix options:

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

    or

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

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template