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


当前回答

窗户呢?

我用的是Windows 10,这个命令对我来说很管用,

php -d memory_limit=-1 "C:\ProgramData\ComposerSetup\bin\composer.phar" update

其他回答

由于之前的答案都不包括set,所以我花了一点时间来弄清楚如何在Windows中做到这一点而不改变php.ini,但下面是对我有效的方法:

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

在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

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

Centos 7使用:

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

在我的例子中:

Windows 10和Docker Desktop工作:

docker-compose -f .docker/docker-compose.yml exec php env COMPOSER_MEMORY_LIMIT=-1 composer require fideloper/proxy