我试图通过运行下面的命令将HWIOAuthBundle添加到我的项目中。

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

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

当我试图运行作曲家要求,我得到了内存错误。

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 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 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文件中设置内存限制为2G,但没有工作。我找到我的php.ini通过运行php -i | grep php.ini


当前回答

在确保供应商文件夹存在之前,请确保不需要包。

检查之前是否安装过composer。您可能只是将存储库克隆到您的机器上。因此,在需要新的包之前,必须先安装旧的包。或者,您可能希望在composer命令中包含这个选项——profile,以查看时间和内存使用信息。

其他回答

在Windows xampp我只是改变:

;memory_limit=512M 

在php.ini中:

memory_limit =-1

然后通过xampp重新启动Apache

结果如下:

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

Here is another way to solve this problem under windows, if you use Wampserver. Indeed at the level of wampserver, there are two php.ini files, that of PHP, which one can find in the location C: \ wamp64 \ bin \ php \ phpx.xx \ php.ini and that of Apache , which can be found at location C: \ wamp64 \ bin \ apache \ apachex.xx \ bin \ php.ini. Both of these files have the memory_limit parameter. So to be sure to solve this problem, it is better to set the memory_limit = -1 parameter in both files at once.

在我的情况下,我试图安装Laravel框架没有说明xampp服务器(或apache服务器)在我的windows系统,我得到以下错误

致命错误:允许的1610612736字节内存耗尽

当我启动xampp服务器(或apache服务器)时,它就开始安装laravel框架,错误就消失了。

所以有时候你必须检查这个,否则它会比平时花费更长的时间,消耗更多的内存,结果大小会被耗尽。

以防你得到一个作曲家错误:

无法打开输入文件:composer

run:

php -d memory_limit=-1 /usr/local/bin/composer require ...

Composer 2.0预览版现已发布:https://github.com/composer/composer/releases 修正了我的问题。你可以用composer self-update来设置预览

编辑:Composer 2与内存调优发布