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


当前回答

这个页面上的选项对我有用

https://www.jesusamieiro.com/php-fatal-error-allowed-memory-size-of-1610612736-bytes-exhausted/

更精确地说,解决方案一:

COMPOSER_MEMORY_LIMIT=-1作曲家更新

其他回答

苹果笔记本电脑: 执行命令sudo nano ~/。bash_profile编辑bash_profile,然后在该文件中添加别名composer="COMPOSER_MEMORY_LIMIT=-1 composer",然后保存并退出。

希望这样能解决问题;编码快乐!

在我的例子中,我丢失了一个交换分区。更多信息:https://github.com/composer/composer/issues/7348#issuecomment-414178276

手册中的另一个解决方案:

Composer也尊重由componer_memory_limit环境变量定义的内存限制:

COMPOSER_MEMORY_LIMIT=-1 composer.phar <...>

或者在我的案例中

export COMPOSER_MEMORY_LIMIT=-1
composer <...>

在我的例子中:

Windows 10和Docker Desktop工作:

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

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

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