1. 程式人生 > 實用技巧 >composer require報錯: Allowed memory size of 1610612736 bytes exhausted

composer require報錯: Allowed memory size of 1610612736 bytes exhausted

報錯資訊:

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)

方法一

看提示應該是記憶體超出了,修改php.ini中memory_limit=-1(不限制記憶體),重啟環境

然後檢視php限制的記憶體,是否修改成功
php -r "echo ini_get('memory_limit').PHP_EOL;"

修改成功後再去composer試試

方法二

上面是網上找到的方法,我按照上面的方法操作後,依舊報錯;可能我的這種情況不適合上面的解決辦法.

接著尋求解決辦法,最終我把要安裝的包直接寫入composer.json中,然後composer update後成功,好吧,就是這麼簡單

"require": {
    "php": "^7.2",
    "ext-json": "*",
    "fideloper/proxy": "^4.0",
    "fruitcake/laravel-cors": "^1.0",
    "laravel/framework": "^6.2",
    "laravel/helpers": "^1.1",
    "laravel/horizon": "^3.6",
    "laravel/scout": "^8.0",
    "laravel/telescope": "^2.1",
    "laravel/tinker": "^2.0",
    "mews/purifier": "^3.1",
    "simplesoftwareio/simple-qrcode": "^3.0"
},