Sites & PHP

.test domains (DNS)

Switch from .localhost to .test and how LaraMonster resolves your domains on each system.

Sites use .localhost by default because it works everywhere with no setup. If you prefer .test (like Laravel Valet and Herd), LaraMonster can point *.test at your computer too.

.localhost: nothing to set up

Browsers, curl and most tools resolve any name ending in .localhost to your own computer, as the internet standard requires. That's why http://blog.localhost:8080 works the moment the folder exists, on every system, offline, without touching system files.

One exception: some command-line tools and PHP's own DNS lookups don't know about .localhost. If your app calls another local site by name (for example an API at api.localhost), use .test with DNS set up, or call 127.0.0.1 with a Host header.

Switching to .test

  1. Change the TLD

    In SettingsDomains (DNS) pick test, or run laramonster tld test. Every site's address changes at once.

  2. Set up DNS

    Click Configure DNS (asks for your password once), or run laramonster dns setup.

  3. Check it

    Settings shows Working, and laramonster dns status says the names resolve.

$ laramonster tld test
$ laramonster dns setup
$ laramonster dns status
$ ping -c1 blog.test               # answers from 127.0.0.1

Remember to update APP_URL in your projects' .env files to the new addresses.

How it works on each system

LaraMonster runs a tiny DNS server on 127.0.0.1:5354 that answers every *.test name with your own computer. dns setup tells your system to ask it, using the best method available:

SystemMethodWhat it changes
macOSResolver fileCreates /etc/resolver/test. Only .test lookups go to LaraMonster.
Linux with systemd-resolvedresolved drop-inCreates /etc/systemd/resolved.conf.d/laramonster.conf with Domains=~test.
Windows, other Linuxhosts fileKeeps one line per site in a block LaraMonster manages in your hosts file. Click Sync hosts file after adding sites.

Undoing it

$ laramonster dns remove
$ laramonster tld localhost

dns remove deletes the resolver file, the systemd-resolved drop-in or LaraMonster's block in the hosts file, depending on the method used.