|
| 1 | +# Laravel Herd Development Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This project is optimized for [Laravel Herd](https://herd.laravel.com), the fastest way to run Laravel locally. Herd provides a zero-configuration local development environment with automatic PHP, Nginx, and database management. |
| 6 | + |
| 7 | +## Why Laravel Herd? |
| 8 | + |
| 9 | +### **Advantages over Traditional Development Stacks** |
| 10 | +- ⚡ **Zero Configuration**: No complex setup or Docker overhead |
| 11 | +- 🚀 **Instant Start**: Projects are immediately accessible |
| 12 | +- 🔄 **Automatic Management**: PHP versions, databases, and services handled automatically |
| 13 | +- 🎯 **Laravel-Optimized**: Built specifically for Laravel development |
| 14 | +- 💾 **Lightweight**: Minimal system resource usage |
| 15 | +- 🔧 **Multiple PHP Versions**: Easy switching between PHP versions per project |
| 16 | + |
| 17 | +### **Herd vs Docker for Local Development** |
| 18 | +| Feature | Laravel Herd | Docker | |
| 19 | +|---------|--------------|---------| |
| 20 | +| **Setup Time** | Instant | Complex configuration | |
| 21 | +| **Resource Usage** | Minimal | High memory/CPU usage | |
| 22 | +| **PHP Version Switching** | One command | Rebuild containers | |
| 23 | +| **Database Management** | Automatic | Manual container setup | |
| 24 | +| **File Permissions** | Native | Permission issues | |
| 25 | +| **Performance** | Native speed | Virtualization overhead | |
| 26 | + |
| 27 | +## Herd Setup for This Project |
| 28 | + |
| 29 | +### **1. Install Laravel Herd** |
| 30 | +```bash |
| 31 | +# Download from https://herd.laravel.com |
| 32 | +# Or install via Homebrew (macOS) |
| 33 | +brew install --cask herd |
| 34 | +``` |
| 35 | + |
| 36 | +### **2. Link Your Project** |
| 37 | +```bash |
| 38 | +# Navigate to your project directory |
| 39 | +cd /path/to/your/laravel-project |
| 40 | + |
| 41 | +# Link the project to Herd |
| 42 | +herd link |
| 43 | + |
| 44 | +# Your project is now available at: |
| 45 | +# http://your-project-name.test |
| 46 | +``` |
| 47 | + |
| 48 | +### **3. Set PHP Version (if needed)** |
| 49 | +```bash |
| 50 | +# Use PHP 8.3 for this project (Laravel 12 requirement) |
| 51 | + |
| 52 | + |
| 53 | +# Verify PHP version |
| 54 | +php --version |
| 55 | +``` |
| 56 | + |
| 57 | +### **4. Database Configuration** |
| 58 | +```bash |
| 59 | +# Herd includes MySQL and PostgreSQL |
| 60 | +# Update your .env file: |
| 61 | +DB_CONNECTION=mysql |
| 62 | +DB_HOST=127.0.0.1 |
| 63 | +DB_PORT=3306 |
| 64 | +DB_DATABASE=your_project_name |
| 65 | +DB_USERNAME=root |
| 66 | +DB_PASSWORD= |
| 67 | + |
| 68 | +# Create database |
| 69 | +herd mysql |
| 70 | +CREATE DATABASE your_project_name; |
| 71 | +``` |
| 72 | + |
| 73 | +## Development Workflow with Herd |
| 74 | + |
| 75 | +### **Starting Development** |
| 76 | +```bash |
| 77 | +# 1. Ensure Herd is running (automatic on system start) |
| 78 | +herd status |
| 79 | + |
| 80 | +# 2. Navigate to project and link if not done |
| 81 | +herd link |
| 82 | + |
| 83 | +# 3. Install dependencies |
| 84 | +composer install |
| 85 | +npm install |
| 86 | + |
| 87 | +# 4. Set up environment |
| 88 | +cp .env.example .env |
| 89 | +php artisan key:generate |
| 90 | + |
| 91 | +# 5. Run migrations |
| 92 | +php artisan migrate --seed |
| 93 | + |
| 94 | +# 6. Start frontend development |
| 95 | +npm run dev |
| 96 | + |
| 97 | +# 7. Open in browser |
| 98 | +herd open |
| 99 | +``` |
| 100 | + |
| 101 | +### **Daily Development Commands** |
| 102 | +```bash |
| 103 | +# Quick project access |
| 104 | +herd open # Open project in browser |
| 105 | +herd open --secure # Open with HTTPS |
| 106 | + |
| 107 | +# Database management |
| 108 | +herd mysql # Access MySQL CLI |
| 109 | +herd tinker # Laravel Tinker |
| 110 | + |
| 111 | +# PHP version management |
| 112 | +herd use [email protected] # Switch to PHP 8.3 |
| 113 | +herd php --version # Check current PHP version |
| 114 | + |
| 115 | +# Service management |
| 116 | +herd restart # Restart all services |
| 117 | +herd logs # View service logs |
| 118 | +``` |
| 119 | + |
| 120 | +## Herd Integration with Project Tools |
| 121 | + |
| 122 | +### **Playwright Testing with Herd** |
| 123 | +```javascript |
| 124 | +// playwright.config.js automatically detects Herd URLs |
| 125 | +// Tests run against http://your-project.test |
| 126 | + |
| 127 | +// Example test |
| 128 | +test('homepage loads correctly', async ({ page }) => { |
| 129 | + await page.goto('/'); // Uses Herd's URL automatically |
| 130 | + await expect(page).toHaveTitle(/Laravel/); |
| 131 | +}); |
| 132 | +``` |
| 133 | + |
| 134 | +### **FluxUI Development** |
| 135 | +```bash |
| 136 | +# Herd serves your project instantly |
| 137 | +# FluxUI components are immediately available at: |
| 138 | +# http://your-project.test |
| 139 | + |
| 140 | +# Watch for changes |
| 141 | +npm run dev # Vite hot reload works seamlessly with Herd |
| 142 | +``` |
| 143 | + |
| 144 | +### **Livewire Development** |
| 145 | +```bash |
| 146 | +# Livewire components update in real-time |
| 147 | +# No additional configuration needed with Herd |
| 148 | + |
| 149 | +# Test Livewire components |
| 150 | +php artisan livewire:make UserForm |
| 151 | +# Available immediately at http://your-project.test |
| 152 | +``` |
| 153 | + |
| 154 | +## Herd-Specific Environment Configuration |
| 155 | + |
| 156 | +### **.env Configuration for Herd** |
| 157 | +```bash |
| 158 | +# Application |
| 159 | +APP_NAME="Laravel 12 Project" |
| 160 | +APP_ENV=local |
| 161 | +APP_URL=http://your-project.test # Herd's automatic URL |
| 162 | + |
| 163 | +# Database (Herd's MySQL) |
| 164 | +DB_CONNECTION=mysql |
| 165 | +DB_HOST=127.0.0.1 |
| 166 | +DB_PORT=3306 |
| 167 | +DB_DATABASE=your_project_name |
| 168 | +DB_USERNAME=root |
| 169 | +DB_PASSWORD= |
| 170 | + |
| 171 | +# Cache/Session (use database for local development) |
| 172 | +CACHE_DRIVER=database |
| 173 | +SESSION_DRIVER=database |
| 174 | +QUEUE_CONNECTION=database |
| 175 | + |
| 176 | +# Mail (use Herd's built-in mail testing) |
| 177 | +MAIL_MAILER=log |
| 178 | +``` |
| 179 | + |
| 180 | +### **Herd Services Configuration** |
| 181 | +```bash |
| 182 | +# Check available services |
| 183 | +herd services |
| 184 | + |
| 185 | +# Available by default: |
| 186 | +# - PHP (multiple versions) |
| 187 | +# - Nginx |
| 188 | +# - MySQL |
| 189 | +# - Redis (if installed) |
| 190 | +# - Mailpit (for email testing) |
| 191 | +``` |
| 192 | + |
| 193 | +## Advanced Herd Features |
| 194 | + |
| 195 | +### **HTTPS/SSL Support** |
| 196 | +```bash |
| 197 | +# Enable HTTPS for your project |
| 198 | +herd secure your-project |
| 199 | + |
| 200 | +# Your project is now available at: |
| 201 | +# https://your-project.test |
| 202 | + |
| 203 | +# Disable HTTPS |
| 204 | +herd unsecure your-project |
| 205 | +``` |
| 206 | + |
| 207 | +### **Custom Domains** |
| 208 | +```bash |
| 209 | +# Use custom domain |
| 210 | +herd link --name=my-awesome-app |
| 211 | +# Available at: http://my-awesome-app.test |
| 212 | + |
| 213 | +# Multiple domains for same project |
| 214 | +herd link --name=api |
| 215 | +# API available at: http://api.test |
| 216 | +``` |
| 217 | + |
| 218 | +### **Environment Isolation** |
| 219 | +```bash |
| 220 | +# Herd automatically isolates projects |
| 221 | +# Each project gets its own: |
| 222 | +# - PHP version |
| 223 | +# - Database |
| 224 | +# - Environment variables |
| 225 | +# - Dependencies |
| 226 | +``` |
| 227 | + |
| 228 | +## Performance Optimization with Herd |
| 229 | + |
| 230 | +### **OPcache Configuration** |
| 231 | +```bash |
| 232 | +# Herd optimizes PHP automatically |
| 233 | +# For development, OPcache is disabled by default |
| 234 | +# For production testing, enable OPcache: |
| 235 | + |
| 236 | +herd php -d opcache.enable=1 artisan optimize |
| 237 | +``` |
| 238 | + |
| 239 | +### **Database Optimization** |
| 240 | +```bash |
| 241 | +# Herd's MySQL is pre-configured for development |
| 242 | +# For performance testing: |
| 243 | + |
| 244 | +# Increase memory limits |
| 245 | +herd mysql |
| 246 | +SET GLOBAL innodb_buffer_pool_size = 128M; |
| 247 | +``` |
| 248 | + |
| 249 | +## Testing with Herd |
| 250 | + |
| 251 | +### **Running Tests** |
| 252 | +```bash |
| 253 | +# Laravel tests (Pest) |
| 254 | +php artisan test |
| 255 | +# or |
| 256 | +pest |
| 257 | + |
| 258 | +# Playwright E2E tests |
| 259 | +npm run test:e2e |
| 260 | +# Tests automatically use Herd's URL |
| 261 | + |
| 262 | +# Test with different PHP versions |
| 263 | + |
| 264 | +php artisan test |
| 265 | +herd use [email protected] # Switch back |
| 266 | +``` |
| 267 | + |
| 268 | +### **Test Database Setup** |
| 269 | +```bash |
| 270 | +# Create separate test database |
| 271 | +herd mysql |
| 272 | +CREATE DATABASE your_project_test; |
| 273 | + |
| 274 | +# Update .env.testing |
| 275 | +DB_DATABASE=your_project_test |
| 276 | +``` |
| 277 | + |
| 278 | +## Troubleshooting |
| 279 | + |
| 280 | +### **Common Issues** |
| 281 | + |
| 282 | +1. **Project not accessible** |
| 283 | + ```bash |
| 284 | + herd restart |
| 285 | + herd unlink && herd link |
| 286 | + ``` |
| 287 | + |
| 288 | +2. **Database connection issues** |
| 289 | + ```bash |
| 290 | + herd mysql # Verify MySQL is running |
| 291 | + # Check .env database credentials |
| 292 | + ``` |
| 293 | + |
| 294 | +3. **PHP version conflicts** |
| 295 | + ```bash |
| 296 | + herd use [email protected] # Ensure correct PHP version |
| 297 | + php --version # Verify |
| 298 | + ``` |
| 299 | + |
| 300 | +4. **Port conflicts** |
| 301 | + ```bash |
| 302 | + herd stop |
| 303 | + # Stop other web servers (Apache, XAMPP, etc.) |
| 304 | + herd start |
| 305 | + ``` |
| 306 | + |
| 307 | +### **Herd Logs** |
| 308 | +```bash |
| 309 | +# View Herd logs for debugging |
| 310 | +herd logs |
| 311 | + |
| 312 | +# View Nginx logs |
| 313 | +herd logs nginx |
| 314 | + |
| 315 | +# View PHP logs |
| 316 | +herd logs php |
| 317 | +``` |
| 318 | + |
| 319 | +## Migration from Other Development Environments |
| 320 | + |
| 321 | +### **From Laravel Valet** |
| 322 | +```bash |
| 323 | +# Valet projects work seamlessly with Herd |
| 324 | +# Simply install Herd and your sites continue working |
| 325 | +``` |
| 326 | + |
| 327 | +### **From Docker/Sail** |
| 328 | +```bash |
| 329 | +# 1. Stop Docker containers |
| 330 | +docker-compose down |
| 331 | + |
| 332 | +# 2. Install Herd and link project |
| 333 | +herd link |
| 334 | + |
| 335 | +# 3. Update .env for Herd's MySQL |
| 336 | +# 4. Run migrations |
| 337 | +php artisan migrate |
| 338 | +``` |
| 339 | + |
| 340 | +### **From XAMPP/MAMP** |
| 341 | +```bash |
| 342 | +# 1. Stop XAMPP/MAMP |
| 343 | +# 2. Install Herd |
| 344 | +# 3. Link existing projects |
| 345 | +herd link |
| 346 | + |
| 347 | +# 4. Update database configuration |
| 348 | +# 5. Import existing databases if needed |
| 349 | +``` |
| 350 | + |
| 351 | +## Integration with Claude Code MCP Servers |
| 352 | + |
| 353 | +### **MCP Server Testing** |
| 354 | +```bash |
| 355 | +# All MCP servers work seamlessly with Herd |
| 356 | +# Playwright MCP uses Herd's URLs automatically |
| 357 | +# Database MCP connects to Herd's MySQL |
| 358 | +# Fetch MCP can test Herd-served endpoints |
| 359 | +``` |
| 360 | + |
| 361 | +### **Development Workflow** |
| 362 | +```bash |
| 363 | +# 1. Herd serves your Laravel app instantly |
| 364 | +# 2. Claude Code can interact with your app via MCP servers |
| 365 | +# 3. Playwright tests run against Herd URLs |
| 366 | +# 4. Database queries work with Herd's MySQL |
| 367 | +# 5. File operations access Herd-managed project files |
| 368 | +``` |
| 369 | + |
| 370 | +## Best Practices |
| 371 | + |
| 372 | +### **Project Organization** |
| 373 | +- Keep projects in organized directories |
| 374 | +- Use descriptive project names for Herd linking |
| 375 | +- Maintain separate databases per project |
| 376 | +- Use version control for environment configurations |
| 377 | + |
| 378 | +### **Performance** |
| 379 | +- Use database caching for local development |
| 380 | +- Enable OPcache for production testing |
| 381 | +- Monitor Herd logs for performance issues |
| 382 | +- Optimize asset compilation with Vite |
| 383 | + |
| 384 | +### **Security** |
| 385 | +- Use HTTPS for projects requiring security testing |
| 386 | +- Keep Herd updated for security patches |
| 387 | +- Use environment-specific configurations |
| 388 | +- Test with realistic data volumes |
| 389 | + |
| 390 | +Laravel Herd provides the perfect foundation for this Laravel 12 + FluxUI + Claude Code development environment, offering unprecedented speed and simplicity for local development while maintaining full compatibility with all project tools and MCP servers. |
0 commit comments