symfony/stopwatch
Symfony Stopwatch is a lightweight profiling utility to measure execution time and memory usage in PHP. Start/stop named events, record laps, and group timings into sections (phases) to benchmark code paths and understand performance bottlenecks.
StopwatchEvent, StopwatchSection) already embedded in Laravel via symfony/console, symfony/http-foundation, etc.composer require symfony/stopwatch:^8.1.0 remains seamless; no additional configuration required.start()/stop() calls, necessitating code changes. No changes to this core requirement in v8.1.0.Handle methods for request-level metrics.@Profile attribute).| Risk Area | Mitigation (Updated for v8.1.0) |
|---|---|
| Manual Instrumentation | Same as before: Start with critical paths (e.g., checkout/search) and use decorators/attributes. |
| Performance Overhead | Disable in production via environment flag (no changes to v8.1.0’s behavior). |
| Version Compatibility | PHP 8.4+ required for v8.1.0 (no regression; aligns with Symfony 7.0+). Test on staging before full adoption. |
| Data Loss | Export to Telescope/DB if historical analysis is needed (unchanged). |
| Team Adoption | Pilot with performance teams; provide templates for common use cases (e.g., queries, APIs). |
| False Positives | Combine with Blackfire/Xdebug for deeper analysis (no changes). |
StopwatchEvent).composer require symfony/stopwatch:^8.1.0.@Profile attribute).| Component | Compatibility Notes |
|---|---|
| Laravel 10/11 | Full compatibility with Symfony 7.0+. PHP 8.4+ required for v8.1.0. |
| PHP 8.1–8.3 | Use Stopwatch v7.x (not v8.1.0). |
| Symfony Components | No conflicts; standalone component. |
| Debugbar | Plug into existing collectors for UI visualization. |
| Telescope | Extend Monitor to store Stopwatch events. |
| Queue Workers | Works in handle() methods of ShouldQueue jobs. |
| Artisan Commands | Profile CLI tasks by wrapping logic in start()/stop(). |
| Middleware | Instrument Handle() methods for request latency. |
start()/stop()), no config, works everywhere.stop() calls (use try-finally blocks).How can I help you explore Laravel packages today?