# 执行 composer required 时报PHP内存溢出的错误

**URL:** <https://www.shiqidu.com/t/topic/723>\
**Category:** 开发调优\
**Tags:** PHP\
**Created:** [2020 年10 月 18 日 10:21 UTC](https://www.shiqidu.com/t/topic/723 "2020-10-18T10:21:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
发布日期： [2020 年10 月 18 日 10:21 UTC](https://www.shiqidu.com/t/topic/723/1 "2020-10-18T10:21:39Z")

</div>

今天安装composer包的时候，报了下面的错

```auto
Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/local/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.ini把`memory_limit`改成-1可以解决此问题，但是这样不太好，可以使用下面的命令临时解决一下。

```bash
php -d memory_limit=-1 /usr/local/bin/composer [require/install/update]

```

> 参考 [Troubleshooting - Composer](https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors)
