我正在尝试通过运行以下命令将 HWIOAuthBundle 添加到我的项目中。
composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
HWIOAuthBundle github: https://github.com/hwi/HWIOAuthBundle
当我尝试运行 composer require 时,出现内存不足错误。
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 文件中将 memory_limit 设置为 2G,但没有成功。我通过运行 php -i | 找到了我的 php.ini grep php.ini
最佳答案
要获取当前的 memory_limit 值,请运行:
php -r "echo ini_get('memory_limit').PHP_EOL;"
尝试增加 php.ini
文件中的限制(例如 /etc/php5/cli/php.ini
类 Debian 系统):
; Use -1 for unlimited or define an explicit value like 2G
memory_limit = -1
或者,您可以使用命令行参数增加限制:
php -d memory_limit=-1 composer.phar require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
要获取加载的 php.ini 文件位置,请尝试:
php --ini
另一个快速解决方案:
php composer.phar COMPOSER_MEMORY_LIMIT=-1 require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
或者只是:
COMPOSER_MEMORY_LIMIT=-1 composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
关于php - Composer 要求内存不足。 PHP fatal error : Allowed memory size of 1610612736 bytes exhausted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49212475/