namshi/cuzzle excels as a debugging utility for Guzzle HTTP clients, aligning well with Laravel’s ecosystem where HTTP requests (API calls, webhooks, external services) are common. It bridges the gap between Laravel’s HTTP layer (e.g., HttpClient, GuzzleHttp\Client) and developer debugging needs.HttpClient (introduced in Laravel 8+) and standalone GuzzleHttp\Client instances are directly supported. No additional wrappers or adapters needed.boot() method) to auto-inject Cuzzle middleware.app('http')->get()).Illuminate\Http\Events\RequestHandled) could trigger Cuzzle for outgoing requests.local environment or for failed requests).tap() or custom middleware).Log::debug() with structured data or a dedicated debug channel.namshi/cuzzle has no external dependencies beyond Guzzle. However, ensure Guzzle version compatibility (e.g., Laravel 10 uses Guzzle 7+).Mockery or GuzzleHttp\HandlerStack to isolate.Cuzzle apply to all Guzzle requests (e.g., API calls, webhooks) or only specific routes/services?debug environment or routes prefixed with /admin.dd($request->toArray())) or packages like spatie/laravel-activitylog for request tracking.Illuminate\Http\Client (Laravel 8+).GuzzleHttp\Client instances.guzzlehttp/guzzle, spatie/laravel-ignition (for error pages), or fruitcake/laravel-cors (if debugging CORS issues).dispatchSync()), ensure Cuzzle is applied pre-dispatch.Cuzzle in a staging environment with a subset of Guzzle requests (e.g., non-critical APIs).config('debug') to toggle logging dynamically.use Namshi\Cuzzle\Cuzzle;
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.example.com', [
'on_stats' => function ($event) {
Cuzzle::dump($event->getRequest());
}
]);
// app/Providers/AppServiceProvider.php
public function boot()
{
if (app()->environment('local')) {
\GuzzleHttp\Client::getDefaultOptions()['on_stats'] = function ($event) {
\Namshi\Cuzzle\Cuzzle::dump($event->getRequest());
};
}
}
// app/Http/Middleware/DebugGuzzleRequests.php
public function handle($request, Closure $next)
{
$response = $next($request);
if ($request->is('api/*')) {
\Namshi\Cuzzle\Cuzzle::dump($request->getGuzzleRequest());
}
return $response;
}
.env checks).composer.json.Cuzzle only in local environment.Cuzzle becomes insufficient, migrate to Laravel Telescope or structured logging (e.g., Monolog handlers).namshi/cuzzle for Guzzle version compatibility.Cuzzle being enabled in production if not gated by environment checks. Mitigate with:
if (!app()->isLocal()) {
throw new \RuntimeException("Cuzzle is disabled in non-local environments.");
}
Cuzzle to output JSON for easier parsing.DEBUGGING.md guide for engineers on how to use Cuzzle effectively.tap() or middleware to filter:
How can I help you explore Laravel packages today?