farayaz/laravel-spy
Lightweight Laravel package that automatically logs all outgoing HTTP client requests. Capture URL, method, headers, payload, response headers/body, status code, and duration, with configurable logging and options to obfuscate sensitive data for debugging and auditing.
Http facade or client..env conventions for toggling features (SPY_ENABLED), obfuscating sensitive data (SPY_OBFUSCATES), and excluding URLs (SPY_EXCLUDE_URLS). This aligns with Laravel’s philosophy of configuration over convention and enables zero-code deployment for observability.http_logs table, providing queryable, long-term storage for auditing and forensics. However, this introduces synchronous write overhead, which could impact performance in high-throughput environments./spy endpoint is basic and read-only, lacking advanced features like real-time monitoring, filtering, or aggregation. Middleware dependencies (e.g., auth) may require additional configuration to avoid conflicts with existing route protections.SPY_CLEAN_DAYS and SPY_FIELD_MAX_ROWS configurations help, but monitoring and tuning may be required for long-term use.Http facade.SPY_REQUEST_BODY_EXCLUDE_CONTENT_TYPES). Misconfiguration could lead to unnecessary storage of large, non-textual data.Http facade and client. Existing Http:: calls (e.g., Http::get(), Http::post()) will be automatically logged without code changes.Initial Setup (Zero-Config):
composer require farayaz/laravel-spy.php artisan vendor:publish --provider="Farayaz\LaravelSpy\LaravelSpyServiceProvider".php artisan migrate.SPY_ENABLED=true, SPY_OBFUSCATES=password,token).Customization Phase:
SPY_EXCLUDE_URLS), obfuscation (SPY_OBFUSCATES), and retention (SPY_CLEAN_DAYS) via .env.http_logs table schema if additional fields are needed (e.g., custom metadata).Advanced Scaling (If Needed):
spy:log job). This requires:
/spy endpoint or build a custom admin panel using Laravel’s resources or a frontend framework (e.g., Livewire, Inertia).Rollback Plan:
SPY_ENABLED=false.http_logs table or archive its data.composer remove farayaz/laravel-spy.Http facade/client. Raw Guzzle instances or other HTTP libraries (e.g., cURL) are not intercepted.app/Http/Kernel.php may need adjustment.Pre-Installation:
SPY_CLEAN_DAYS) and storage capacity.Installation:
.env.Customization:
php artisan spy:clean) via Laravel’s scheduler.Monitoring:
Production Rollout:
SPY_ENABLED to toggle logging dynamically (e.g., disable in production for non-critical paths).How can I help you explore Laravel packages today?