Switch Laravel Valet from .dev to .test in three easy steps

Chrome and Safari began forcing https for the .dev domain because someone apparently thought it was a good idea to register as a public TLD. Laravel Valet only produces self-signed SSL certificates though, so I want to keep my local installations served as http. Guess it's time to switch TLDs!

Oh, and don't try to use .local on a Mac because it conflicts with Bonjour local networking. I discovered this with 30 minutes of wasted effort. .test is the way to go.

First, run:

valet domain test

Switch Valet to using the .test domain, which will also update dnsmasq accordingly. Don't try to edit dnsmasq configuration on your own — there are too many ways to go wrong.

Second, run:

wp package install wp-cli/find-command

Install wp-cli/find-command to find all WordPress installs in your Laravel project directory. It's convenient for running one WP-CLI command against all WordPress installs.

Third, run:

wp find ~/projects --field=wp_path | xargs -I % wp --path=% search-replace '.dev' '.test' --all-tables

Run wp search-replace against all WordPress installs to replace instances of '.dev' with '.test'. ~/projects is my Valet project directory, and --all-tables ensures the procedure is run against all database tables.

Et voila! You've switched Laravel Valet from .dev to .test in three easy steps.