Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)

在使用composer安装依赖时:

composer require ******/******

报如下错误:

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)...

解决方法:

修改全局配置php.ini

memory_limit = 512M
修改为
memory_limit = -1

临时参数修改

php -d memory_limit=-1 /usr/local/bin/composer require ******/******

意思是,不限制内存,

其中 /usr/local/bin/composer 为composer路径,可以输入composer -h查看:

php /usr/local/bin/composer help list