farayaz/laravel-spy
Zero-config Laravel package to spy on outgoing HTTP calls. Automatically logs Laravel Http facade and Guzzle requests with URL, method, headers, payload, response/status, and duration. Includes configurable logging and obfuscation for sensitive data.
Pros:
http_logs enables querying (e.g., "Find all failed Stripe API calls last week") and integration with Laravel’s query builder.Cons:
http_logs), adding schema management and potential storage costs for high-volume applications.SPY_FIELD_MAX_LENGTH but not ideal for large payloads).Stack Fit:
Http:: facade and Guzzle, covering 90%+ of HTTP use cases in Laravel applications. Works alongside existing middleware (e.g., retry, timeout).Migration Path:
SPY_ENABLED=false to verify compatibility.SPY_EXCLUDE_URLS to whitelist critical APIs while excluding non-essential endpoints.SPY_CLEAN_DAYS (default: 7 days).spy:clean via Laravel’s task scheduler (app/Console/Kernel.php).Compatibility:
pdo, mbstring).Http::macro() or explicit middleware ordering.Data Privacy and Compliance:
*:password,token,secret,key,api_*).SPY_DASHBOARD_ENABLED) or custom queries.SPY_DASHBOARD_MIDDLEWARE = ['auth:admin']).Performance Impact:
artisan spy:load-test or custom scripts).LogHttpRequest job) by extending the package’s event system.SPY_EXCLUDE_URLS (e.g., static asset APIs).Operational Overhead:
SPY_CLEAN_DAYS=7 initially and adjust based on retention needs (e.g., 30 days for compliance).http_logs table size via Laravel Telescope or custom health checks.Debugging Complexity:
SPY_FIELD_MAX_LENGTH).SPY_FIELD_MAX_LENGTH judiciously (default: 255) to balance detail and storage.LoggedRequest model’s accessors./up) from logging to reduce noise.Maintenance and Updates:
composer.json during initial adoption (e.g., ^1.5.0).Laravel Ecosystem:
Http facade and Guzzle clients, covering 90%+ of HTTP use cases. Works alongside existing middleware (e.g., RetryMiddleware, TimeoutMiddleware).spy:clean) integrates with Laravel’s scheduler for automated log retention.Non-Laravel Components:
HttpClient, cURL). Workaround: Wrap calls in Laravel’s Http facade.Third-Party Integrations:
How can I help you explore Laravel packages today?