Composer 需要内存不足.PHP 致命错误:允许的内存大小为 1610612736 字节已用完 [英] Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted

查看:51
本文介绍了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.

使用版本 ^0.6.0@dev for hwi/oauth-bundle 使用版本 ^1.2@dev对于 php-http/guzzle6-adapter 使用版本 ^1.10@dev forphp-http/httplug-bundle ./composer.json 已更新 Loading带有包信息的作曲家存储库更新依赖项(包括 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 字节已用完的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆