Laravel Herd Deep Dive: The Ultimate Native Development Environment

· 7 min read

Introduction

Laravel Herd is a native development environment tool for macOS and Windows, developed by Beyond Code (the team behind Expose, Tinkerwell). Unlike Docker or XAMPP, Herd runs PHP and services directly on your machine with optimal performance.

Why Choose Herd?

Criteria Herd Docker/Sail Valet XAMPP
Performance ⭐⭐⭐⭐⭐ ⭐⭐⭐ ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐
Setup time 1 minute 5-15 minutes 5 minutes 10 minutes
Resource usage Low High Low Medium
Multiple PHP ✅ Easy
GUI ✅ Beautiful
Price Free/Pro Free Free Free

Installation

macOS

  1. Download from herd.laravel.com
  2. Open the .dmg file and drag to Applications
  3. Launch Herd - Done!

Windows

  1. Download the installer from the website
  2. Run the installer
  3. Restart your computer (if needed)
  4. Done!

After installation, Herd automatically sets up:

  • PHP (latest version)
  • Nginx
  • dnsmasq (for .test domains)
  • Composer
  • Laravel Installer

Interface and Basic Features

Sites

Herd manages sites through "parked" directories. Default is ~/Herd:

# Every folder in ~/Herd automatically gets a .test domain
~/Herd/
├── blog/           → blog.test
├── shop/           → shop.test
└── api-backend/    → api-backend.test

Add another directory:

# Terminal
herd park ~/Projects

# Or via GUI: Sites → Park Path

PHP Versions

One of Herd's most powerful features is managing multiple PHP versions:

# Check current version
herd php -v

# List available versions
herd php:list

# Switch global PHP
herd use php@8.3

# Switch PHP for a specific site
herd isolate php@8.2 --site=legacy-project

Via GUI:

  1. Click the Herd icon
  2. Sites → Select site
  3. PHP Version → Choose version

SSL/HTTPS

# Enable SSL for a site
herd secure blog

# Disable SSL
herd unsecure blog

# Enable SSL for all sites
herd secure --all

After securing, access https://blog.test - the certificate is automatically trusted!

Herd Pro: Advanced Features

Herd Pro ($99/year) adds many important features for professional development:

1. Database Services

# MySQL
herd services mysql start
herd services mysql stop

# PostgreSQL
herd services postgres start

# Redis
herd services redis start

# Check status
herd services

Database connection:

MySQL:
- Host: 127.0.0.1
- Port: 3306
- User: root
- Password: (empty)

PostgreSQL:
- Host: 127.0.0.1
- Port: 5432
- User: postgres
- Password: (empty)

2. Xdebug Integration

# Enable Xdebug
herd xdebug on

# Disable Xdebug (increases performance)
herd xdebug off

VS Code Configuration:

// .vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/Users/you/Herd/blog": "${workspaceFolder}"
            }
        }
    ]
}

3. Mail Catcher (Mailpit)

Herd Pro integrates Mailpit to catch emails in development:

# Start Mailpit
herd services mailpit start

# Open Mailpit UI
herd open mailpit
# Or access http://localhost:8025

Laravel configuration:

# .env
MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

4. Node.js Integration

# Check Node version
herd node -v

# Use specific Node version
herd node use 20

# Run npm/yarn through Herd
herd npm install
herd yarn dev

5. MinIO (S3-compatible Storage)

herd services minio start

# Access MinIO Console
# http://localhost:9001
# Username: minioadmin
# Password: minioadmin

Laravel configuration:

FILESYSTEM_DISK=s3

AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=minioadmin
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=local
AWS_ENDPOINT=http://localhost:9000
AWS_USE_PATH_STYLE_ENDPOINT=true

Advanced Configuration

Custom Nginx Configuration

Herd allows custom Nginx config per-site:

# Create custom config
herd nginx:config blog

This creates file ~/.config/herd/config/valet/Nginx/blog.test:

server {
    listen 127.0.0.1:80;
    server_name blog.test;
    root /Users/you/Herd/blog/public;

    # Custom configuration
    client_max_body_size 100M;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

PHP Configuration

# View PHP config
herd php:ini

# Open php.ini for editing
herd php:ini --edit

Common adjustments:

; ~/.config/herd/config/php/82/php.ini

memory_limit = 512M
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 300

; Opcache settings
opcache.enable = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 10000

Environment Variables

Set environment variables for all PHP processes:

# Open config file
herd php:ini --edit

# Or create file ~/.config/herd/config/php/environment
CUSTOM_VAR=value
API_KEY=secret

CLI Commands Reference

Site Management

# List all sites
herd sites

# Link a directory with custom name
herd link ~/Projects/my-app my-custom-name
# Access at my-custom-name.test

# Unlink
herd unlink my-custom-name

# Open site in browser
herd open blog

# View logs
herd log blog

# Tail logs realtime
herd log blog --tail

PHP Management

# PHP REPL
herd tinker

# Run PHP code
herd php -r "echo phpinfo();"

# Composer commands
herd composer install
herd composer require laravel/sanctum

# Artisan commands
herd artisan migrate
herd artisan queue:work

Service Management

# View all services
herd services

# Restart all
herd restart

# Restart Nginx
herd restart nginx

# Restart PHP
herd restart php

Real-World Workflows

Workflow 1: New Laravel Project

# 1. Create new project
cd ~/Herd
laravel new my-project

# 2. Secure with HTTPS
herd secure my-project

# 3. Open in browser
herd open my-project

# 4. Start required services
herd services mysql start
herd services redis start

# 5. Setup database
herd artisan migrate

Workflow 2: Clone Existing Project

# 1. Clone into Herd directory
cd ~/Herd
git clone git@github.com:company/project.git

# 2. Install dependencies
cd project
herd composer install
herd npm install

# 3. Copy environment
cp .env.example .env
herd artisan key:generate

# 4. If project needs older PHP
herd isolate php@8.1

# 5. Setup database
herd artisan migrate --seed

# 6. Build assets
herd npm run build

Workflow 3: Multiple Projects with Different PHP Versions

# Project 1: Laravel 11 (PHP 8.3)
herd isolate php@8.3 --site=modern-app

# Project 2: Legacy Laravel 8 (PHP 8.0)
herd isolate php@8.0 --site=legacy-app

# Project 3: Symfony 6 (PHP 8.2)
herd isolate php@8.2 --site=symfony-app

# Verify
herd sites
# modern-app.test   PHP 8.3
# legacy-app.test   PHP 8.0
# symfony-app.test  PHP 8.2

IDE Integration

VS Code

Install the "Laravel Herd" extension for:

  • Site switching
  • PHP version switching
  • Service management
  • Quick commands

Settings:

{
    "php.validate.executablePath": "/Applications/Herd.app/Contents/Resources/herd/bin/php",
    "php.executablePath": "/Applications/Herd.app/Contents/Resources/herd/bin/php"
}

PHPStorm

  1. Settings → PHP → CLI Interpreter
  2. Add → Local Path
  3. Path: /Applications/Herd.app/Contents/Resources/herd/bin/php

Xdebug:

  1. Settings → PHP → Debug
  2. Port: 9003
  3. Start Listening for PHP Debug Connections

Troubleshooting

Site Not Loading

# Check Herd is running
herd status

# Restart services
herd restart

# Check DNS
ping blog.test
# Should return 127.0.0.1

502 Bad Gateway

# Check PHP is running
ps aux | grep php-fpm

# Restart PHP
herd restart php

# View error log
herd log blog

Database Connection Refused

# Check service is running
herd services

# Start MySQL
herd services mysql start

# Check port
lsof -i :3306

SSL Certificate Issues

# Regenerate certificates
herd unsecure blog
herd secure blog

# Trust certificate manually (macOS)
herd trust

Comparison with Other Solutions

Herd vs Laravel Sail (Docker)

When to use Herd:

  • Personal development
  • Need high performance
  • Don't want to learn Docker
  • Multiple PHP versions for different projects

When to use Sail:

  • Team development (consistent environment)
  • Production parity is important
  • Complex service dependencies
  • CI/CD integration

Herd vs Valet

Herd is essentially an evolution of Valet with:

  • More beautiful GUI
  • Easier management
  • Pro features (databases, services)
  • Windows support

If you're using Valet and happy with it, you don't necessarily need to switch. But for newcomers, Herd is a better choice.

Tips & Tricks

1. Useful Aliases

# ~/.zshrc or ~/.bashrc

alias h="herd"
alias hp="herd php"
alias hc="herd composer"
alias ha="herd artisan"
alias hs="herd services"
alias ho="herd open"

2. Quick Database Reset

# Reset and re-seed
ha migrate:fresh --seed

# With specific seeder
ha migrate:fresh --seed --seeder=TestDataSeeder

3. Temporary PHP Version

# Run command with specific PHP version without isolating
herd php@8.1 artisan migrate
herd php@8.2 composer install

4. Performance Monitoring

# Check memory usage
herd php -r "echo memory_get_usage(true) / 1024 / 1024 . ' MB';"

# Opcache status
herd php -r "print_r(opcache_get_status());"

Conclusion

Laravel Herd is currently the best development environment tool for PHP developers:

  • Zero configuration: Install and run in 1 minute
  • Native performance: Significantly faster than Docker
  • Multiple PHP versions: Easy switching
  • Beautiful GUI: No need for terminal for everything
  • Pro features: Database, Xdebug, Mail catcher...

If you're a Laravel developer not using Herd yet, try it now - you won't want to go back!

References

Comments