WordPress Local Development on macOS with Valet and Bedrock

Laravel’s Valet tool makes spinning up a local development environment quick and painless for macOS users. Valet uses Nginx, 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.test.

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.test.

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.

Join the discussion on Roots Discourse

Help support our open-source development efforts

Help us grow

Join over 7,800+ subscribers on our newsletter to get the latest Roots updates, along with occasional tips on building better WordPress sites.

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?

“Easily the best WordPress email I get.” Colin OBrien

Follow us on Twitter @rootswp

Ready to checkout?