Changing PHP CLI memory limit on the fly

Photo by Peter Masełkowski on Unsplash Photo by Peter Masełkowski on Unsplash

There are some tasks in laravel that a php artisan would just be enough.

But there are tasks that would just consume the php config memory_limit.

You can always update your php.ini file and increase the memory_limit=1G for example or you can do this in your cli:

1
php -d memory_limit=1G heavy_script.php

or

1
php -d memory_limit=1G artisan command:name
Checking PHP ini and version file via CLI or file script

Cheers!