沃梦达 / 编程问答 / php问题 / 正文

Composer 要求内存不足.PHP致命错误:允许的内存大小为1610612736字节已用尽

Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted(Composer 要求内存不足.PHP致命错误:允许的内存大小为1610612736字节已用尽)

本文介绍了Composer 要求内存不足.PHP致命错误:允许的内存大小为1610612736字节已用尽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过运行以下命令将 HWIOAuthBundle 添加到我的项目中.

I am trying to add HWIOAuthBundle to my project by running the below command.

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

HWIOAuthBundle github:https://github.com/hwi/HWIOAuthBundle

HWIOAuthBundle github: https://github.com/hwi/HWIOAuthBundle

当我尝试运行 composer require 时,出现内存不足错误.

When I try to run composer require I am getting the out of memory error.

为 hwi/oauth-bundle 使用版本 ^0.6.0@dev 使用版本 ^1.2@dev对于 php-http/guzzle6-adapter 使用版本 ^1.10@devphp-http/httplug-bundle ./composer.json 已更新包含包信息的作曲家存储库更新依赖项(包括require-dev)

Using version ^0.6.0@dev for hwi/oauth-bundle Using version ^1.2@dev for php-http/guzzle6-adapter Using version ^1.10@dev for php-http/httplug-bundle ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev)

PHP 致命错误:允许的内存大小为 1610612736 字节已用尽(试图分配 67108864 字节)在phar:///usr/local/Cellar/composer/1.4.2/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php 在第 220 行

PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/local/Cellar/composer/1.4.2/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220

致命错误:允许的内存大小为 1610612736 字节已用尽(已尝试分配 67108864 字节)在phar:///usr/local/Cellar/composer/1.4.2/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php 在第 220 行

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/local/Cellar/composer/1.4.2/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220

我尝试在我的 php.ini 文件中将 memory_limit 设置为 2G,但没有成功.我通过运行 php -i | 找到了我的 php.inigrep php.ini

I tried setting the memory_limit to 2G in my php.ini file but did not work. I found my php.ini by running php -i | grep php.ini

推荐答案

要获取当前的 memory_limit 值,运行:

To get the current memory_limit value, run:

php -r "echo ini_get('memory_limit').PHP_EOL;"

尝试增加 php.ini 文件中的限制(例如,对于类似 Debian 的系统,/etc/php5/cli/php.ini):

Try increasing the limit in your php.ini file (ex. /etc/php5/cli/php.ini for Debian-like systems):

; Use -1 for unlimited or define an explicit value like 2G
memory_limit = -1

或者,您可以使用命令行参数增加限制:

Or, you can increase the limit with a command-line argument:

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

要获取加载的 php.ini 文件位置尝试:

To get loaded php.ini files location try:

php --ini

另一个快速解决方案:

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

或者只是:

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

这篇关于Composer 要求内存不足.PHP致命错误:允许的内存大小为1610612736字节已用尽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Composer 要求内存不足.PHP致命错误:允许的内存大小为1610612736字节已用尽

基础教程推荐