Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Stopwatch Plugin

Stopwatch Plugin Laravel Package

php-http/stopwatch-plugin

Symfony Stopwatch integration for HTTPlug: wraps HTTP client requests in a plugin to measure request/response timings and profiling data via Symfony’s Stopwatch component. Install with Composer and use alongside other php-http plugins.

View on GitHub
Deep Wiki
Context7

Symfony Stopwatch plugin for HTTPlug

Frequently asked questions about Stopwatch Plugin
How do I integrate this Stopwatch plugin with Laravel’s HTTP client (Guzzle or Symfony HttpClient)?
Replace your existing Guzzle client with an HTTPlug `PluginClient` wrapped around a Guzzle adapter (e.g., `php-http/guzzle7-adapter`). Add the `StopwatchPlugin` to the plugins array in the client config. Laravel’s service container can then bind this client globally for consistent timing across requests.
Will this work with Laravel’s built-in HTTP facade (e.g., `Http::get()`)?
Yes, but you’ll need to bind the HTTPlug client with the Stopwatch plugin to Laravel’s service container. Replace `Http::client()` calls with your container-bound client, or use middleware to wrap existing HTTP requests with the Stopwatch plugin.
Does this plugin support Laravel 10+ and Symfony 6+ components?
Yes, the plugin is compatible with Laravel 10+ and Symfony 6+ due to its reliance on PSR-18/HTTPlug standards. Ensure your Laravel app’s Symfony components (e.g., `symfony/http-client`) are up-to-date to avoid version conflicts.
How can I log Stopwatch events to Laravel’s Monolog system?
Use Symfony’s `StopwatchEventListener` to subscribe to Stopwatch events and forward them to Monolog. Configure the listener in Laravel’s service provider to log events like `http.request` or `http.response` with custom formatting.
Can I use this plugin to monitor external API calls in Laravel queues or jobs?
Yes, wrap the HTTPlug client used in your queue jobs or jobs with the Stopwatch plugin. Bind the client to the container or pass it directly to job constructors. This ensures timing metrics are captured even for async HTTP calls.
What’s the performance overhead of adding this plugin to my HTTP requests?
The overhead is minimal—typically under 1ms per request—due to its lightweight design. Benchmark in your staging environment to confirm it meets your latency requirements, especially for high-frequency API calls.
How do I customize event names or filter specific HTTP calls from being timed?
Configure the `StopwatchPlugin` with custom event names via its constructor or plugin options. Use HTTPlug’s middleware to filter requests (e.g., exclude internal routes) before they reach the Stopwatch plugin.
Does this plugin work with Laravel Debugbar or Blackfire for deeper profiling?
Yes, the Stopwatch plugin collects raw timing data that can be exported to Debugbar or Blackfire via custom collectors. Combine it with existing tools for a unified observability stack, but avoid duplicate metrics.
How do I test this plugin in Laravel’s PHPUnit tests without hitting real APIs?
Use `php-http/mock-client` to mock HTTPlug clients in your tests. Replace the real client with a mock in your test setup, then verify Stopwatch events are triggered with expected timing data.
What are the alternatives to this plugin for HTTP request timing in Laravel?
Alternatives include Laravel Debugbar (for UI-based profiling), Blackfire (for deep performance analysis), or custom middleware using `microtime()`. However, this plugin is unique in its HTTPlug integration, making it ideal for PSR-18 clients like Guzzle or Symfony HttpClient.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
bugban/symfony
beyonder-capi/workflow-extensions-bundle
beyonder-capi/job-queue-bundle
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin