在利用PHP软件开发过程中,我们时常会用到composer做依赖管理,但是在一个项目时,我们有个同事,正常执行composer install提示内存超出的问题,具体报错如下
PS D:\devww> composer install Loading composer repositories with package information Updating dependencies (including require-dev) Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 67108872 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSet.php on line 84 Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
此时,我们可以在cmd命令中,执行看看php环境,当前的大小,命令行如下,且看到我本机的是2g
PS D:\devww\tySdk> php -r "echo ini_get('memory_limit').PHP_EOL;" 2048M
这个对php熟悉的就知道了。我们需要更改php.ini中的memory_limit信息,可以设置为-1就是无限制了,如果你是用的phpstudy做的开发环境,可以直接修改,如下图所示
最后记得要重启下,php。发现正常了。
文章来源:PHP软件开发团队