我试图通过运行下面的命令将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


当前回答

我使用php7.2,大小默认设置为memory_limit = 512M。 要增加大小,需要定位php.ini。

在Wamp中,它位于C:\wamp64\bin\php\php7.2.23\php.ini。请注意PHP版本,因为它是名称文件夹,在我的情况下,我有php7.2.23

在Laragon中,它位于C:\ Laragon \bin\php\php-7.2.23- win32 - vc15 -x64\php.ini中。

如果您不想允许无限的空间,您可以设置任何您方便的大小,在我的例子中,我使用memory_limit = 2G

如果希望允许无限空间,可以更改为memory_limit = -1

其他回答

最近发现,Composer在具有大量历史标记的包上消耗了大量CPU +内存。看到作曲家/作曲家# 7577

这个问题的解决方法是使用symfony/flex或https://github.com/rubenrua/symfony-clean-tags-composer-plugin

composer global require rubenrua/symfony-clean-tags-composer-plugin

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

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

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

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

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.

在我的情况下,当我得到这个错误时,我试图要求这个包。

你可以像这样运行,你不需要更新PHP INI文件:

COMPOSER_MEMORY_LIMIT=-1 composer require huddledigital/zendesk-laravel

Mac php 7.4

run

php --ini

Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File:         /usr/local/etc/php/7.4/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed:      /usr/local/etc/php/7.4/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.4/conf.d/php-memory-limits.ini

如果解析了额外的.ini文件: Memory_limit需要在

/usr/local/etc/php/7.4/conf.d/php-memory-limits.ini

正如Jose Seie所写,设置内存为

memory_limit = -1 or memory_limit = 1G