我试图通过运行下面的命令将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://github.com/composer/composer/issues/7348#issuecomment-414178276

其他回答

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

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

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

只是想分享一下我在这件事上的情况。

问题背景:

在一个流浪的盒子里运行作曲家。 在尝试运行composer require " laravell -doctrine/orm:~1.4.13"后得到此消息:

致命错误:在phar:///usr/local/bin/composer/src/ composer/ DependencyResolver/RuleWatchGraph.php第52行中,允许的内存大小为1610612736字节已耗尽(试图分配4096字节) 有关如何处理内存不足错误的更多信息,请访问https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors。

已尝试将php.ini内存限制设置为-1。(仍然没有工作)。

解决方案:

显然是我的作曲家。Json和composer。洛克有一些问题。 运行$ composer validate,结果是: “锁文件不符合composer的最新更改。Json,建议您运行composer update。 所以我运行$ composer update,所有依赖项都被解析了。依我之见,当依赖关系出现问题时,可能是树的构建不同步,因此出现内存不足的问题。

希望这对大家有所帮助。

窗户呢?

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

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

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.

只需设置memory_limit,指定编写器的完整路由。Phar文件和更新,在我的情况下使用命令:

php -d memory_limit=-1 C:/wamp64/composer.phar update