Moving from Homestead to Valet for WordPress Development

I used to use Homestead for local WordPress and Craft development. It was nice because everything worked out of the box. Well, theoretically. In reality, it worked about 80% of the time, but 20% of the time I’d get cryptic errors from Vagrant like:

Some box with the same name exists. We won’t tell you where, but trust us, it exists and that can’t happen.

The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what went wrong.

Error! You have to destroy this box and rebuild it. Hope you backed up those local databases, because they are gone forever!

It was always a rabbit hole of headaches that could take half a day to resolve. Most resolution happened in the form of me destroying a box and rebuilding it, losing my databases. So much fun.

Today I got the SSH error again and had enough. I went looking for a better solution and found Valet. Their pitch:

Valet is a Laravel development environment for Mac minimalists. No Vagrant, no /etc/hosts file. You can even share your sites publicly using local tunnels.

Sounds great. It won’t eat my battery, RAM, CPU, or take gigs of disk space for vitual machines. Sign up the heck up.

It was super easy to set up with tools I already use: Homebrew and Composer. Instructions here.

The only tricky part was making composer directory available in my Mac’s PATH, since I’ve only ever used it inside individual projects. Turns out with zsh you have to give the explicit path, you can’t just use ~/, so I added this to my .zshrc: export PATH=/Users/cagrimmett/.composer/vendor/bin:$PATH

Once I loaded the profile with source ~/.zshrc, I was good to go. I linked my main projects folder so Valet knows where to look for projects, changed my wp-config.php files to point at my local mysql database instead of Homestead’s, then navigated to project-folder-name.test and was good to go!

Valet runs at startup, so I don’t have to run cd ~/Homestead && vagrant up anymore, just brew services start mysql@5.7 if I need a database running (which you usually do for WordPress development.)

I like that Valet makes it so easy to use different PHP versions. For example, to use 7.2, you go to your command line and type: valet use php@7.2

I’m looking forward to never using Vagrant or VirtualBox again. Peace out