Set Up a Fast Local Laravel Environment with Herd

A step-by-step Laravel Herd setup on macOS: install Herd, serve every project on a .test domain, pin a PHP version per site, and add trusted local HTTPS.

Steven Richardson
Steven Richardson
· 7 min read

Every Laravel project needs the same boring plumbing before you can write a line of code: a PHP runtime, a web server, DNS for a local domain, and a certificate if you want HTTPS. I've spent enough hours wiring up nginx by hand and rebuilding slow Docker images to appreciate a tool that just hands me a working *.test environment. That tool is Herd, and this is the exact laravel herd setup I run on a fresh Mac.

Herd is a native environment — it ships pre-compiled PHP, nginx, dnsmasq and Node binaries, so there's no Homebrew PHP to babysit and nothing to compile. If you've been reaching for a multi-stage Docker build to run Laravel locally, Herd is the faster path for day-to-day development on macOS. Follow the six steps below and you'll have a project serving over HTTPS in about fifteen minutes.

Install Herd and finish onboarding#

Download the Herd DMG, drag the app into your Applications folder, and open it. The first launch kicks off an onboarding process that downloads the latest stable PHP version (currently PHP 8.5) and installs a background service. That service needs admin permission because it manages nginx and dnsmasq for you — approve the prompt when macOS asks. Herd requires macOS 12.0 or later; a Windows build exists too, but this walkthrough is macOS-first.

Once onboarding finishes you have a full PHP and Laravel toolchain on your PATH. Verify it from any terminal:

herd --version
php --version
laravel --version
composer --version
node --version

If those all print versions, you're done — Herd doesn't touch your existing services, so you can switch back to your old setup any time. It's a natural first install when you're assembling the rest of a modern Laravel toolchain.

Serve your projects from a parked directory#

Herd serves sites using parked paths. By default it parks ~/Herd, which means any PHP application you drop in that folder is instantly reachable at <directory-name>.test — no config, no restart. This is the whole point: put a project in the parked directory and it's live.

If your code lives elsewhere, add extra parked paths in Herd's general settings, or link a single project (covered in the next step). To confirm the default parked directory is working, create the folder if it doesn't exist and drop a project in:

# ~/Herd is parked automatically on install
cd ~/Herd

Anything served here resolves through dnsmasq, so my-app.test maps to your local project without editing /etc/hosts.

For a brand-new app, the fastest route is the bundled laravel binary inside the parked directory. Create the project, then let Herd open it in your browser and editor:

cd ~/Herd
laravel new my-new-site
cd my-new-site
herd open
herd edit

That's a working site at https://my-new-site.test with zero extra setup. For an existing project that lives outside ~/Herd, use herd link from the project root — it registers the site using the directory name as the domain, or a custom name if you pass one:

cd ~/Sites/your-project
herd link              # served at your-project.test
herd link custom-domain # also served at custom-domain.test

Linking is how I bring legacy repos online without moving them, and it pairs well with a Makefile that streamlines project onboarding for the rest of the team.

Pin the PHP version per site#

Herd uses one global PHP version for every site, which you set with herd use. That's fine until you have an older project that hasn't been upgraded yet. To install and switch the global version:

herd php:list          # see installed versions and their status
herd php:install 8.3   # install a specific version
herd use 8.4           # set the global default

When a single site needs a different version, isolate it from the project root. Herd then always serves that site with the pinned version regardless of the global default:

cd ~/Herd/legacy-app
herd isolate 8.2       # this site now runs on PHP 8.2
herd isolated          # list every isolated site
herd unisolate         # revert to the global version

Inside an isolated site, use herd php, herd composer and herd which-php to proxy CLI calls to the correct version — handy so Composer resolves dependencies against the version the site actually runs on.

Secure a Herd site with TLS#

By default Herd serves over plain HTTP. Some workflows — OAuth redirects, secure cookies, service-to-service calls — need HTTPS. The herd secure command issues a trusted local certificate and serves the site over TLS with HTTP/2. Run it from the project root, or name the site from anywhere:

herd secure                 # secure the current directory's site
herd secure my-new-site     # secure my-new-site.test from anywhere

Your site is now reachable at https://my-new-site.test with a valid certificate — no browser warnings. To check which sites hold a certificate, run herd secured; to revert a site to HTTP, run herd unsecure. If a browser keeps forcing HTTPS after you unsecure, restart the browser — Chrome in particular caches the HTTPS redirect aggressively.

Add a database#

New Laravel applications default to SQLite, so you can build and test immediately without standing up a database server. When you need MySQL, PostgreSQL or Redis, you have three options: install the vendor service directly, use the free DBngin app to manage it, or upgrade to Herd Pro and add the service from the Services tab in a couple of clicks.

Herd ships the PHP extensions for MySQL, MariaDB, PostgreSQL, Redis and SQLite out of the box, so once a service is running you only need to point your .env at it:

# .env — pointing a Herd site at a local MySQL service
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_new_site
DB_USERNAME=root
DB_PASSWORD=

Run php artisan migrate and you're connected. Herd Pro adds a GUI for MySQL, PostgreSQL, Redis, Meilisearch, MinIO and Laravel Reverb if you'd rather manage everything from one window.

Handle the common gotchas#

Herd is smooth, but a few things trip people up, so handle them up front. On first launch Herd detects an existing Laravel Valet installation and offers to migrate all your sites, certificates and settings — if Valet is still running, Herd asks you to stop it first. It never modifies your Valet install, so you can quit Herd and run valet start to go back.

If you use the Fish shell, the Herd binaries won't be on your PATH automatically. Add them once with fish_add_path -U $HOME/Library/Application\ Support/Herd/bin/ and restart the shell.

The free version of Herd covers the entire environment described above — PHP, sites, per-site versions and TLS. Database and cache service management, local mail viewing and log monitoring live in Herd Pro. You don't need Pro to follow this guide; SQLite plus DBngin will get you a full stack for free.

Finally, the default PHP version moves as new releases land. If php --version doesn't match what you expect, check herd php:list and confirm whether the site is isolated — an isolated site ignores the global version by design.

Wrapping up#

Herd turns "set up a local Laravel environment" from an afternoon into fifteen minutes: install, drop a project in ~/Herd, pin PHP if you need to, and run herd secure for HTTPS. It's the first thing I install on a new Mac before anything else.

Once your site is serving, wire up your day-to-day debugging: tail application logs live with Laravel Pail, and dump queries and Livewire state to a desktop window with Ray. Both slot straight into the Herd environment you just built.

FAQ#

What is Laravel Herd?

Herd is a native PHP and Laravel development environment for macOS (with a Windows build available). It bundles pre-compiled PHP, nginx, dnsmasq and Node binaries, so it runs without Docker or Homebrew and serves every project on a *.test domain. It's conceptually similar to Laravel Valet but ships with no external dependencies, which makes it fast to install and use.

Is Laravel Herd free?

Yes. The core Herd environment — PHP, site serving, per-site PHP versions and TLS certificates — is free. Herd Pro is a paid upgrade that adds service management for databases and caches, local mail viewing, and log monitoring. You can build a complete local stack for free by combining Herd with SQLite or the free DBngin database manager.

How do I switch PHP versions in Herd?

Set the global version with herd use 8.4, and install new versions with herd php:install. To give one project a different version, run herd isolate 8.2 from that project's root — Herd then always serves that site with the pinned version, regardless of the global default. Run herd isolated to see every isolated site and herd unisolate to revert one.

How do I get an HTTPS URL for a Herd site?

Run herd secure from the project directory, or herd secure my-site from anywhere, to issue a trusted local certificate and serve the site over TLS with HTTP/2. The site is then reachable at https://my-site.test with no browser warnings. Use herd secured to list secured sites and herd unsecure to switch a site back to plain HTTP.

Can Herd migrate my existing Valet sites?

Yes. The first time you open Herd it automatically detects an existing Valet installation and migrates all your sites, certificates and settings. If Valet is still running it asks you to stop it first. Herd never modifies your Valet installation, so you can quit Herd and run valet start to switch back at any time.

Steven Richardson
Steven Richardson

CTO at Digitonic. Writing about Laravel, architecture, and the craft of leading software teams from the west coast of Scotland.