給專案安裝依賴包時,有時候會遇到這個問題
PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
Check getcomposer.org/doc/articles/troub... for more info on how to handle out of memory errors.%
大概就是記憶體不足的意思,看了很多網友的解決方案都是修改 memory_limit = -1
,但是我並不想為了安裝依賴包去修改 PHP 配置,針對這個問題, Composer 官方給出了多個解決方案。
其中透過臨時設定記憶體大小 COMPOSER_MEMORY_LIMIT=-1
正好符合我需求。
例如:COMPOSER_MEMORY_LIMIT=-1 composer require "spatie/laravel-permission:~3.0"
本作品採用《CC 協議》,轉載必須註明作者和本文連結