Yesterday, Taylor Otwell released Laravel Valet, a development environment for Mac minimalists. It didn’t take long before Taylor also released a driver for WordPress, which is why I thought I’d do a write-up here on the blog.
Valet is a super simple approach to development environments. I use Vagrant every day and I love it. It’s just that sometimes… Sometimes you just need something simple that just works! Well, Valet is that. If you are just curious to know more about Valet, jump to the bottom of this post, where I go over a few general questions. Feel free to add any additional questions you might have in the comments.
Note: Valet is Mac only. If you are looking for a super simple cross-platform alternative, check out Wocker.
Before we get started, you can also check out Adam Wathan‘s awesome ad spot for Valet:
Installing Laravel Valet is very straight forward, given you have a few things already set up on your Mac. I’m not going to go over the process here, because Taylor already wrote some great documentation for you.
The 2 main things you need in order to install Valet are Homebrew and Composer. I couldn’t get it to work with my current version of Homebrew, so I scrapped it and reinstalled it. After that everything worked like a charm. You are going to use Homebrew to install PHP 7 before you install Valet. As for the database, I followed Taylor’s recommendation and installed MariaDB (a better alternative to MySQL) with Homebrew as well.
Setting up a WordPress site
Valet has a WordPress driver (you can create your own drivers if you need something else), so out of the box, it supports running WordPress sites. It’s actually smart enough to figure out which driver to use, so there’s zero configuration needed, other than the usual WordPress stuff.
There are 2 ways Valet can serve your sites: The
park or the
link option. The
park option can be used to add a whole folder to Valet. Every folder in there will then be mapped to a site and get it’s own .dev domain. So if you add
~/Sites to Valet and there have a folder in there named
wp-valet, the content of that folder will be served when you visit http://wp-valet.dev in your browser. No setup required! The
link option can be used to serve a single site, without adding a whole directory.
Here’s how I used the
park command to add a folder to Valet:
$ mkdir ~/Sites
$ cd ~/Sites
$ valet park
That’s literally it. Then I went ahead and used WP-CLI to install WordPress:
$ mkdir wp-valet
$ cd wp-valet
$ wp core download
I then jumped over in Chrome and visited http://wp-valet.dev and that’s it! Super simple.
Sharing your site (this is cool)
Valet can do something that’s pretty cool, by using ngrok. Imagine that you’re working on something locally that you need to quickly show someone. What do you do? Set up a staging site just for that? On a subdomain? On another domain? Just a screenshot maybe? Well, if you’re using Valet, you can just type
valet share in your Terminal app and Valet will setup a secure tunnel to your localhost and give you a link to share! Pretty cool stuff.
When you’re done sharing, you just hit Ctrl-C and the tunnel will be closed again.
A few more things
Here are a few answers to some questions you might be having. Please ask questions in the comments and I’ll add them here as well!
Does Valet mess with my hosts file?
Nope. It uses dnsmasq to capture all requests to .dev domains (unless you have an entry for them in your
Which server is Valet running on?
Valet is using the built-in server in PHP, which was introduced in PHP 5.4. Valet runs on PHP 7.
When should I use Valet and not Vagrant?
I personally use Vagrant for larger projects, where I have a lot of dependencies, such as older versions of PHP, and like to work in an isolated environment. What I intend to use Valet for is those quick and dirty things, where you just need something to run right now. I don’t like installing to much stuff on my Mac, so if that’s required, I’d rather work in a Vagrant box.
Have more questions? Just post a comment below and I’ll add it here!
I hope you found this post useful! Now, go check out Valet.
WP Pusher – Git for WordPress
This post was brought to you by WP Pusher.
WP Pusher keeps all your client websites up-to-date whenever you push a change to GitHub or Bitbucket. Visit our website to learn more about WP Pusher.