Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sander0105's avatar

Valet & php environment variables

Thought I share this one since it took some time to figure it out and might help others.

I have an old Laravel 4 app running that relies on php environment variables to switch between production and local development mode, basically switching between .env and config files. In my particular case it would default to production (so not have debug enabled for instance...) and check for a LARAVEL_ENV=local being set.

Laravel valet uses php-fpm, which has a php-fpm.conf. If installed through BREW this file is located at $ /usr/local/etc/php/7.0/php-fpm.conf. I've added the following to the file

[www]
env[LARAVEL_ENV] = 'local'

Restart laravel valet should get the environment variable set for all domains.

0 likes
0 replies

Please or to participate in this conversation.