How to Change PHP.ini Configuration on Mac for Laravel Valet

If you are using Laravel Valet for local development on your Mac then you might need to change the php.ini configuration to suit your needs. It can be either increasing memory_limit, max_execution_time etc.

If you want to configure/setup Laravel Valet on Mac M1 then you can follow my previous article here.

Recently, I wrote an article about how to configure PHP Monitor which provides you the visual information about Laravel Valet and different configurations. It can also let you local PHP configuration file php.ini

By default all the PHP versions will be located in /usr/local/etc/php

Let's say, your current active version of PHP is 7.3 and you want to change the max_execution_time value. Go to the following location: /usr/local/etc/php/7.3

Here you will find php.ini file which is the main configuration file. But there is another file php-memory-limits.ini located inside the conf.d folder. By default this fill will have the following configuration:

; 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

which overrides the main php.ini file configurations.

For max_execution_time you can add it to this file with your desired value and the whole file will look like this:

; 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

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 1800

Restart the PHP and verify your changes.

72