Overview Laravel Herd 1.11 transforms the local development experience by bridging the gap between your local environment and remote infrastructure. This update focuses on three core pillars: automation through the new `herd.yml` specification, deep visibility via the integrated SPX profiler, and seamless Laravel Forge synchronization. These features reduce the friction of environment setup and performance debugging, allowing developers to focus on writing code rather than managing server state. Prerequisites To follow this tutorial, you should have a baseline understanding of the Laravel framework and basic command-line proficiency. You will need a macOS machine with Laravel Herd installed. Access to a Laravel Forge account is required for the integration features, and Herd Pro is necessary for the advanced Dump UI improvements. Key Libraries & Tools * **Laravel Herd**: A lightning-fast native macOS development environment. * **Laravel Forge**: A server management and deployment service. * **SPX**: A low-overhead PHP profiling extension. * **Laravel Reverb**: A first-party WebSocket server for Laravel. Automating Environments with herd.yml The introduction of `herd.yml` is a massive win for team collaboration. Instead of manually documenting PHP versions or required services, you now codify them. Running `herd init` in your terminal triggers an interactive setup that detects your current environment and creates a configuration file. This file ensures that every developer on your team uses the exact same PHP version, secures the site via HTTPS, and spins up the necessary services like Redis or MySQL. ```yaml Example herd.yml structure generated after herd init name: example-app php: 8.3 https: true services: - mysql - redis - typesense integrations: forge: demo-site-id ``` When a new developer pulls the repository, they simply run `herd init`. The tool reads the YAML file and automatically configures the local site to match the project requirements, including port assignments and service dependencies. Deep Performance Profiling with SPX Performance bottlenecks often hide in plain sight. Herd 1.11 integrates SPX, a profiling tool that stays dormant until explicitly called, ensuring no performance penalty during standard development. You can profile CLI commands directly by replacing the `php` prefix with `herd profile`. ```bash Profile a slow Artisan command herd profile artisan slow-command ``` For web requests, Herd provides a dedicated dashboard at `/herd/profiler`. Once enabled, it captures detailed call graphs for every request. This allows you to inspect the execution time of specific methods, such as a slow `Sleep()` call or a heavy database interaction, with microsecond precision. Advanced Debugging with the Enhanced Dump UI The Dump UI in Herd Pro now acts as a full-scale telemetry hub. It goes beyond simple `dump()` outputs to capture database queries, view data, and outgoing HTTP requests. A standout feature is the automatic variable name detection. If you dump a variable named `$user`, the UI explicitly labels it as such, removing the guesswork when multiple objects are dumped in sequence. Furthermore, the Query tab now allows for duration thresholds. You can configure the UI to ignore fast queries and only display those exceeding 700ms, immediately highlighting potential database optimizations without cluttering your log with routine lookups. Syntax Notes and Best Practices * **Active Profiling**: Use the `herd profile` command only when debugging; while SPX is low-overhead, the generated reports consume disk space. * **Version Control**: Always commit your `herd.yml` file to Git. It serves as the single source of truth for your local environment setup. * **Secure WebSockets**: When using Laravel Reverb, always enable the "Serve over HTTPS" option in Herd settings to maintain protocol consistency with your secured local site. Tips & Gotchas * **Read-Only Environment**: The new Forge integration displays your remote `.env` file in a read-only view. This prevents accidental production changes but means you must use the Forge web UI for edits. * **Forge CLI Context**: The Forge CLI now automatically detects your site context because of `herd.yml`. You no longer need to manually specify server IDs when running `forge deploy-logs` or `forge ssh`.
SPX
Products
Sep 2024 • 1 videos
High activity month for SPX. Laravel among the most active voices, with 1 videos across 1 sources.
Sep 2024
- Sep 12, 2024