$ lexprog.com

// notes from an old coder -- php, databases, and the occasional rant

[October 28, 2024] Laravel

Laravel Herd: Local Development

Laravel Herd: Local Development

────────────────────────────────────────────────────────

Laravel Herd: Local Development

Tip: Zero-Config Serving

Drop your Laravel project in ~/Herd and it's automatically served at project.test.

Gotcha: PHP Version per Project

Right-click the Herd menu → choose PHP version per project.

Tip: Valet Alternative

Herd is the successor to Laravel Valet. No need for Homebrew or manual configuration.

Gotcha: Database Included

Herd includes MySQL and PostgreSQL. No separate installation needed.

Tip: SSL Certificates

Herd auto-generates SSL certificates for all .test domains.

Gotcha: Not for Production

Herd is development-only. Use proper server setup for production.

Tip: Use route:cache Carefully

php artisan route:cache is fast, but it doesn't work with closure-based routes. Every time you cache routes, Laravel serializes them. If you have Route::redirect() or closure callbacks, the cache breaks. Stick to controller-based routes in production.

Tip: Model APP_KEY Rotation

Rotating APP_KEY invalidates all encrypted data — cookies, encrypted DB columns, and password reset tokens. If you must rotate (e.g., after a leak), plan a migration that re-encrypts existing data with the new key.

Gotcha: Local Scope Leaks

Global scopes defined in booted() apply to ALL queries on that model — including relationships. An innocent User::all() in admin panel might exclude soft-deleted users if a global scope is active.

Senior Insight

Local development environments are deeply personal — every developer has their preference, and that's fine. The key is consistency across the team. Whether you use Herd, Sail, Laragon, or plain Valet, the team should agree on one setup and document the onboarding process. I've wasted more time debugging 'environment differences' than actual bugs. A standardized docker-compose.yml checked into version control is worth more than any local dev tool.

Source: Laravel News (https://laravel-news.com/), Freek.dev (https://freek.dev/tags/laravel), Spatie Blog (https://spatie.be/blog)

────────────────────────────────────────────────────────
<-- back to posts