A while back, Chrome 63 forced all .dev domains to be HTTPS. As a result, I found myself unable to view my local development websites on Chrome. Even though I have been happy with Chrome lately (it’s a resource hog) it’s still my go-to web development browser.
My local WordPress development environment was powered by DesktopServer, and changing the top level domain involved changing a core configuration file. It wasn’t very hard, but it did lead me to try out other local development environments, just in case something like this happened again.
My criteria for a local dev environment was this:
- Lightweight. I preferred not to use Virtual Box as a dependency, so as not to take up too much disk space. Also, it would be nice if I didn’t have to wait a while for it to start up.
- Flexible. I actually did not want to bundle the dev environment with my project. The projects I work on vary in folder structure, so I wanted to make sure they all can fit inside this environment. Also, I wanted the option of changing top level domains.
- Relatively low cost. I’m open to paying for an app, but given the number of free alternatives out there, I was mainly looking at open source projects.
Installation for Valet was fairly straightforward, but not without its snags. I used Homebrew to install Valet and its dependencies including PHP 7.1 and MySQL. After I ran the final valet install command, I found that I was unable to ping
foobar.test as described in the docs.
Some searching led me to a thread to try this:
brew services restart dnsmasq
brew services restart nginx
brew services restart php71
After that, I was able to ping
foobar.test. Thankfully, I don’t need to do this every time I start my computer.
Serving site with Laravel was delightfully easy. There are two commands,
valet park and
valet park lets you register a working directory, and any directory created in that folder will be its own domain. For example, if I run
valet park in my
~/Sites directory, I can then install WordPress in the
~/Sites/mysite/ directory and view it at
valet link allows me to link a specific folder, say
~/Sites/anothersite/web/ as the root directory for a development domain. I can then run
valet link testsite to have it run on
Valet was built for the Laravel framework, but out of the box it supports a good number of PHP frameworks and CMSes. It also allows you to serve unsupported frameworks and applications with special considerations by using custom Valet drivers.
By default Valet uses the
.test domain. I can easily change that to
app by running
valet domain app. There is no need to change folder structures or folder names. This ensures that Chrome will never block your local site!
Finally, it was also easy to serve a local site over HTTPS by running
valet secure mysite. Both Chrome and Safari seemed satisfied with the generated SSL certificate, but Firefox still flagged it as insecure.
What I Liked
Valet met my criteria for a local development environment: it was flexible, lightweight, and free. I was able to easily configure certain global settings without having to rename folders. The installation was fairly straightforward, and the docs were pretty easy to follow.
What I Didn’t Like
Valet uses the command line, which for some people is a dealbreaker. I didn’t necessarily mind that, but I’ll admit sometimes it was hard to tell if services were up and running. While the use of Homebrew made installation simpler, I didn’t like how I was pretty much on my own if a Homebrew install failed.
There were two minor annoyances that weren’t exactly Valet’s fault. First, I installed MySQL via Homebrew, and I found that sometimes my sites would lose connection to the database. I’m not sure why that is, and it didn’t happen often enough for me to investigate it further. Second, I use BrowserSync with my gulp setup. With Valet, BrowserSync doesn’t work, and I haven’t spent the time to figure out why it wasn’t working.
Would I use Valet for local development? Yes, I’m still using it! Although with the release of DesktopServer 3.8.4, browsers forcing SSL on .dev domain is no longer an issue. Since I’ve had less issues with DesktopServer, I think I might use the two in conjunction. I will host the majority of my local sites on DesktopServer. For sites that are too complex for DesktopServer, I can easily switch over to Valet and serve it there instead.
Have you used Valet? How do you like it?