Gọi lệnh composer install dính lỗi : PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 33554432 bytes) in phar:///usr/local/Cellar/composer/2.0.8/ ....

Xử lý lỗi PHP Fatal error Allowed memory size of 1610612736 bytes exhausted tried to allocate 33554432 bytes in phar

2022-01-27 907 lượt xem

Lỗi composer install

Khi gọi lệnh composer install thì dính lỗi :

Updating dependencies (including require-dev)
PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 33554432 bytes) in phar:///usr/local/Cellar/composer/2.0.8/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 129

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 33554432 bytes) in phar:///usr/local/Cellar/composer/2.0.8/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

Nguyên nhân

Do php memory bị limit, nếu dùng xampp thì bạn tăng size memory lên. Nếu trong action php trong controller thì bạn set cho nó lệnh không tính limit php như sau : 

ini_set('memory_limit', '-1'); 

Nhưng nếu đang trong terminal chạy composer thì bạn có thể thêm tham số như sau: 

php -d memory_limit=-1 /usr/local/bin/composer install 

Chúc các bạn fix được nhiều bug 😄