- How does saloonphp/laravel-plugin compare to Laravel’s built-in HTTP client (Http::)?
- Unlike Laravel’s Http::, which is request-focused, this plugin organizes HTTP logic into reusable *Connectors* (e.g., StripeConnector) tied to your domain. It adds Laravel-native features like config publishing, facades, and Artisan commands, while maintaining Saloon’s fluent API for complex APIs like GraphQL or SOAP.
- Can I use this plugin with Laravel 10+ and PHP 8.3?
- Yes, the plugin supports Laravel 10+ and PHP 8.3, but ensure your underlying *saloonphp/saloon* package is also compatible. Check the plugin’s Composer requirements and Saloon’s changelog for breaking changes, as Saloon v2+ may introduce PHP 8.3-specific features.
- How do I mock Saloon connectors in Laravel’s PHPUnit tests?
- Use the built-in `MockConnector` class. Replace your connector binding in tests with `MockConnector::shouldReceive('fetchUser')->andReturn($mockData)`. This integrates with Laravel’s testing helpers and avoids HTTP calls entirely, speeding up unit tests.
- Does this plugin support OAuth 2.0 or JWT authentication?
- Yes, Saloon’s connectors support OAuth 2.0 and JWT via middleware. Configure it in your connector’s `withMiddleware()` method or globally in `config/saloon.php`. For OAuth, use Saloon’s `OAuth2` decorator or Laravel’s `Sanctum`/`Passport` integration with custom middleware.
- Will this plugin work with Laravel’s queue system for async HTTP requests?
- Absolutely. Use Saloon’s `shouldQueue()` method on connectors or wrap requests in Laravel’s `Bus::dispatch()`. This is ideal for webhooks, background syncs, or rate-limited APIs. Configure queue drivers in Laravel’s `.env` as usual.
- How do I integrate Saloon’s connectors with Laravel’s service container?
- Bind connectors in your `AppServiceProvider` using Laravel’s container: `$this->app->bind(StripeConnector::class, fn() => new StripeConnector(config('services.stripe.key')))`. This enables dependency injection in controllers/services and leverages Laravel’s singleton management.
- Can I use this plugin for SOAP or GraphQL APIs, not just REST?
- Yes, Saloon natively supports SOAP and GraphQL. Define your connector’s `endpoint()` and `method()` to handle these protocols, then use Saloon’s decorators like `GraphQL` or `Soap`. The plugin’s facades and middleware work identically across all three.
- What’s the performance impact of using Saloon vs. raw Guzzle?
- Saloon adds minimal overhead compared to Guzzle. For high-volume APIs, optimize with Saloon’s `cache()` decorator or Laravel’s cache drivers. Async queues (via `shouldQueue()`) further reduce latency for background tasks.
- How do I debug failed Saloon requests in Laravel?
- Enable Saloon’s debug mode with `Saloon::debug()` or leverage Laravel’s logging. For middleware issues, check `app/Http/Kernel.php` and use `tap()` to inspect request/response objects. The plugin integrates with Laravel’s `tap()` for real-time debugging.
- Are there alternatives to this plugin for Laravel HTTP clients?
- Alternatives include Laravel’s native `Http::` client, Guzzle’s standalone PHP library, or packages like *spatie/laravel-http-client*. However, this plugin uniquely combines Saloon’s robust HTTP abstraction with Laravel’s ecosystem (config, events, queues), making it ideal for complex APIs or teams using Saloon’s DDD approach.