How I configured (Laravel) Valet + PHP to send ALL email to Mailhog on Mac w/ Homebrew

I needed to configure PHP + Valet to send any and all emails to Mailhog. This is how I configured my system:

Basically:

brew install mailhog
brew services start mailhog

Then in /opt/homebrew/etc/php/<version>/conf.d/z-php.ini Add:

sendmail_path=/opt/homebrew/bin/mailhog sendmail

Then:

brew services restart php
valet restart

…and if you are using valet isolate in a specific site, also:

valet isolate php@<version>

This should tell that version of PHP to send ANY email via /opt/homebrew/bin/mailhog sendmail which should end up in the Mailhog UI at http://127.0.0.1:8025.

You can also:

valet proxy mailhog.test http://127.0.0.1:8025

And use mailhog.test to access Mailhog.

Code

How I configured NIGINX + Valet to stop the 504 Gateway Time out during long XDebug Sessions

In this video I explain how to stop NGINX (installed via Valet) from 504 Gateway Time-out during long XDebug sessions.

By default this is set to 30 seconds, so if I was debugging something for longer than 30 seconds it would timeout and I would have to restart my xDebug session — annoying!

After doing some research, I finally figured out how to include an NGINX configuration file with these configurations:

proxyconnecttimeout 1200;

proxyreadtimeout 1200;
proxysendtimeout 1200;

fastcgireadtimeout 1200;
fastcgisendtimeout 1200;

Note, you can add these directly to /opt/homebrew/etc/nginx/nginx.conf before any Valet configs are loaded, e.g.:

    proxyconnecttimeout 1200;
    proxyreadtimeout 1200;
    proxysendtimeout 1200;
    fastcgireadtimeout 1200;
    fastcgisendtimeout 1200;

    include "/Users//.config/valet/Nginx/*";
    include servers/*;
    include valet/valet.conf;

…but I opted to use include and load a configuration file that way.

I also review some updates to my last video on my XDebug configuration and how I also configured PHP timeouts to also be higher.