今天在使用composer安装扩展包时报错,如下:

PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///www/server/php/74/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///www/server/php/74/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.#   

解决方式:

php -d memory_limit=-1 /usr/bin/composer require xxxx/xxxxxxx
php -d memory_limit=-1 /usr/bin/composer install

参考: https://www.wjcms.net/archives/2020-10-05-20-03-19