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

其他回答

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

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

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

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

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

COMPOSER_MEMORY_LIMIT=-1 composer require huddledigital/zendesk-laravel

窗户呢?

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

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

同样的问题,没有任何与“memory_limit”相关的工作,但是..

composer self-update --2

..解决了我的问题。(升级:1.10.17 -> 2.0.4)

如果增加内存限制没有帮助或您没有太多内存

在另一台高内存的机器上

将composer的内存限制设置为-1 删除作曲家。锁文件 运行composer install 提交作曲家。锁定文件到您的回购 然后在服务器上运行composer install

这个想法是在计算/创建composer时使用了大部分内存。锁文件,如果它的创建/就绪- composer安装将不会使用太多内存。