This post assumes that you are using Laravel Valet on your local for development.
When working on different project, most of the time we might need to switch from one
PHP version to another. Each
PHP version has default setting that might not be enough for your project and when running tasks like
phpunit it can easily exhaust your memory and you might get a message like this one:
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 172032 bytes)
To solve this following are the steps:
/usr/local/etc/php and locate your
PHP version. Let's say your
PHP version is
7.4 and you need to open
php-memory-limits.ini locate at:
In this file you can set your memory limit as well as other custom settings that you might need and here is an example:
; Max memory per instance
memory_limit = 512M
;The maximum size of an uploaded file.
upload_max_filesize = 512M
; Sets max size of post data allowed.
; Changes to this will also need to be reflected in Nginx with client_max_body_size
; This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 512M
After updating the file then you should restart
PHP using the following command:
valet restart php