Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

Dead simple domain mapping in Laravel Homestead

Michael Dyrynda wrote up a follow up on my homestead tips blog post:

Now that you’ve setup dnsmasq, you can resolve *.dev to your Homestead machine easily, but you still need that manual step of either configuring a new domain in your Homestead.yaml file or using the servecommand within the virtual machine itself.

Whilst neither of these methods take a particularly long time to complete, it’s still a few seconds of repetition that can be avoided with some tweaking of your default nginx configuration using wildcard hosts.

What we’ll be doing, is telling nginx to listen for anything sent to it that isn’t explicitly configured and look for the domain name in your (default) /home/vagrant/Code directory.


Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band.