Serve your local sites with Valet

Remove the need for Vagrant, MAMP, Homestead or PHPs server.

  • 6th May 2016

Most Mac developers I know, use MAMP, Vagrant or even the built-in PHP server to serve and develop their sites locally.

All of these have their pros and cons:

  • MAMP has a built-in MySQL database, but can only host a single site at a time.
  • Vagrant is flexible as hell but can take a bit of time to set up. Having a virtual machine for each site can also be a resource hog.
  • PHPs local server is great, flexible and lightweight, but having to start it each time can be a pain. Having to remember the current point can also be a chore. Finally, working with .htaccess files can also cause issues.

Enter Valet.

Valet is another creation by Taylor Otwell, owner of the Laravel framework.

If like me, you keep all your sites in a central folder (repos in my case), you can point Valet to this folder, run valet park and voilà, your blog/ directory will then be accessible at blog.dev.

If your sites are scattered across multiple locations on your machine, just navigate to your project and add each one with $ valet link app-name.

Valet will even automatically start each time your machine boots up.

Hopefully, this will help to develop your local sites much easier!

For more information and a guide to how to get started, see the Valet docs.

Update: Valet has just been updated to use Caddy, instead of PHPs built in server. This means that it won't be long before extra features such as automatic HTTPS via LetsEncrypt is added. All the more reason to use Valet!

Update 2: Valet since switched to using Nginx. Support for automatically creating self signed SSL certificates was also added using valet secure.