Engineering

Using Laravel Herd to Set Up Local WordPress Dev Environment

Laravel Herd is a new kid on the block that comes as a “replacement” for the Laravel Valet. In this quick article we’ll cover what it is, pros and cons of using it and how to set up a local WordPress development environment.

So, Herd is a lightning-fast, macOS-based development environment tailored for Laravel but also works with WordPress and PHP. Packed with essential tools like PHP and nginx, it provides everything you require to kickstart your WordPress development environment.

Pros

  1. It doesn’t require a VM to be run in order for it to work.
  2. It uses static binaries for PHP and nginx, which makes is really really fast.
  3. It gives you ability to manage different PHP versions with a single click (PHP 7.4, 8.0, 8.1, 8.2, 8.3).

Cons

  1. It doesn’t support any other OS other than macOS.
  2. There’s no way of installing PHP extensions at the moment.

Install Herd

Go to this link and download the DMG file. Open the file and drag the Herd icon to the Applications folder. Once it’s installed, open it up.

Install WP-CLI

WP-CLI is an amazing tool that can help you out with all things WordPress related. So let’s install it.
Open up your Terminal and run the following command:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Next step is to move it so that you can use wp command – so run the following commands:

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Creating our first WordPress Website

Open up your terminal once again and:

  1. Go to the Herd projects directory:
    cd ~/Herd
  2. Create a new folder and open it up:
    mkdir example && cd example
  3. Download WordPress:
    wp core download
  4. Configure website database:
    wp core config --dbname=example --dbuser=root --dbpass=
    wp db create
  5. Install WordPress:
    wp core install --title=Example --url=example.test --admin_user=example_user --admin_email=example_user@email.com --admin_password=example_password
  6. Clean up the WordPress install:
    wp site empty --yes
  7. Remove all plugins and themes that we don’t need:
    wp plugin delete --all && wp theme delete --all
  8. Make sure that the website uses https:
    wp search-replace http https
  9. Then, open up Herd Settings -> Sites and click on the little lock icon next to your example website or simply run the following command inside your WordPress project:
    herd secure

Now your WordPress website is up and running and you can access it by typing in your browser its address: https://example.test