今天在使用composer安装扩展包的时候,报了如下的错误,记录一下解决的方法。
一、报错如下
/var/www/html/backend # composer require swooletw/laravel-swoole
Warning from https://mirrors.aliyun.com/composer: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
Using version ^2.6 for swooletw/laravel-swoole
./composer.json has been updated
Loading composer repositories with package information
Warning from https://mirrors.aliyun.com/composer: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 129
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 129
Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors./var/www/html/backend #
二、解决方法
1.方法一:修改php.ini里面的memory_limit的值为 -1
vim /etc/php.ini
; Maximum amount of memory a script may consume
; http://php.net/memory-limit
memory_limit = -1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2.方法二:用如下命令安装
php -d memory_limit=-1 /usr/local/bin/composer require xxx/xxx
#/usr/local/bin/composer是composer的安装路径
执行结果如图
网友评论