WordPress Local Development on OS X with Valet and Bedrock

Laravel’s Valet tool makes spinning up a local development environment quick and painless for OS X users. Valet uses the Caddy web server, PHP 7, along with MariaDB. It can be installed in just a few minutes with Homebrew and Composer.

Bedrock Valet setup

Valet or Trellis

We recommend using Trellis to have dev/prod parity, but sometimes you need something quick and fast for testing or a demonstration. Instead of having to wait for a vagrant up to finish, Valet sites are immediately available once configured.

Valet is also compatible with Craft CMS, Statamic, static HTML and other applications. It will quickly prove to be a useful tool to have running on your machine regardless of your primary development workflow.

Installing Valet

Check to make sure that you don’t have any web servers already running on port 80, such as from MAMP or previously configured local Apache/Nginx servers. Also make sure that Valet’s dependencies have been installed before moving on:

  • Homebrew (Already installed? Run brew update first)
  • Composer with your PATH set

    • Add export PATH="$PATH:$HOME/.composer/vendor/bin" to your profile (.zshrc, .bashrc, etc.)

Now open your Terminal and run the following commands:

# Install PHP 7.0
$ brew install homebrew/php/php70

# Install Valet
$ composer global require laravel/valet

# Install DnsMasq and configure Valet to launch on system start
$ valet install

# Install MariaDB
$ brew install mariadb

Setting up Bedrock sites

Create a Valet directory for your Bedrock sites (since my Trellis installs and other projects typically live in ~/Sites, I’m using a subdirectory) and link it:

$ mkdir ~/Sites/valet
$ cd ~/Sites/valet
$ valet park

Any subfolders you create from ~/Sites/valet are now sites that are served from http://your-project-folder-name.dev.

To create a new Bedrock site, use the wp-cli-valet-command WP-CLI package by @aaemnnosttv:

$ wp package install aaemnnosttv/wp-cli-valet-command:^1.0
$ wp valet new my-project --project=bedrock

You can now access your new development site at http://my-project.dev.

Additional resources

The Valet docs explain the tool in more detail, including how to use valet share to share your local sites with anyone in the world.

Valet also supports vanilla WordPress installations, although typically you’d never want to use a regular WordPress installation over Bedrock.

Thank you to Evan Mattson (@aaemnnosttv) for contributing the Bedrock driver to Valet.

Read the discussion on our Discourse

Get our latest updates & occasional tips on building better WordPress sites

Follow @rootswp on Twitter