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

Saloon Laravel Package

saloonphp/saloon

Saloon is a PHP HTTP client framework for building API integrations. Define connectors and requests, handle authentication, retries, and responses, and test easily with fakes and mocking. Works great in Laravel or any PHP app.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

Saloon is a highly specialized HTTP client abstraction layer designed to replace ad-hoc Guzzle/cURL implementations with a structured, maintainable SDK framework. It aligns well with Laravel’s ecosystem due to:

  • PSR-18 Compliance: Leverages Symfony’s HTTP client under the hood, ensuring compatibility with Laravel’s DI container and HTTP stack.
  • Laravel-Specific Enhancements: Features like psrResponse header handling (v3.15.0) and macroable traits (v3.15.0) integrate seamlessly with Laravel’s service providers and Facades.
  • Modular Design: Encourages domain-specific connectors (e.g., StripeConnector, ShopifyConnector) that can be registered as Laravel services, promoting SOLID principles and testability.
  • Middleware Support: Aligns with Laravel’s middleware pipeline (e.g., logging, retries, auth) via handler stacks (v3.15.0), enabling reuse of existing Laravel middleware.

Key Misalignments:

  • Overhead for Simple APIs: If your use case involves <3 APIs with minimal auth/retries, Saloon’s abstraction may introduce unnecessary complexity.
  • Learning Curve: Requires adoption of Saloon’s DSL (e.g., Request, Connector, Response) and testing patterns (e.g., MockClient), which may slow down teams unfamiliar with the package.

Integration Feasibility

Integration Vector Feasibility Notes
Laravel Service Provider High Saloon’s Connector classes can be bound as Laravel services with config-driven endpoints.
Existing Guzzle Clients Medium Requires migration effort to rewrite clients using Saloon’s Request classes.
OAuth2/PAT Auth High Built-in OAuth2, TokenAuthenticator, and ClientCredentialsGrant (v3.10.0) support.
GraphQL/REST Hybrid Medium Saloon is REST-focused; GraphQL would need custom middleware or a wrapper.
Event-Driven APIs Low Not designed for Webhooks/SSE; would require polling or external event handlers.
Testing (Pest/PHPUnit) High MockClient and fixtures (v3.13.0) simplify API testing.

Critical Dependencies:

  • PHP 8.1+: Required for modern Saloon features (e.g., attributes, enums).
  • Symfony HTTP Client: Core dependency; conflicts unlikely but require version alignment.
  • Laravel 9+: For full PSR-18/PSR-7 integration (e.g., psrResponse in v3.15.0).

Technical Risk

Risk Area Severity Mitigation
Security Vulnerabilities High Critical fixes in v4.0.0 (CVE-2026-33942, CVE-2026-33182) require immediate upgrade.
Breaking Changes Medium v4.0.0 introduces foundational improvements (e.g., base URL overrides); test thoroughly.
Performance Overhead Low Minimal if used correctly; avoid over-fetching or excessive middleware.
Vendor Lock-in Medium Saloon’s DSL is opinionated; migrating back to Guzzle would require refactoring.
Testing Complexity Low Fixtures and MockClient reduce flakiness but require setup.

Key Questions for the Team:

  1. Auth Complexity: Do we need multi-authenticator support (v3.4.0) or custom OAuth flows beyond Saloon’s defaults?
  2. Error Handling: Should we extend Saloon’s exceptions (e.g., PaymentRequired in v3.10.0) or layer Laravel’s Handler?
  3. Observability: How will we log/monitor Saloon requests? (e.g., middleware for OpenTelemetry or Laravel’s logging).
  4. Deprecations: Are we prepared to migrate from deprecated methods (e.g., sendAndRetry in v3.6.4)?
  5. Testing Strategy: Will we use Saloon’s fixtures or integrate with Laravel’s Mocker (e.g., for database-backed APIs)?

Integration Approach

Stack Fit

Saloon is optimized for Laravel due to:

  • PSR-18/PSR-7 Compliance: Works natively with Laravel’s HTTP client and Symfony’s components.
  • Facade/Service Provider Support: Can be exposed as a Saloon Facade or injected via DI.
  • Laravel-Specific Features:
    • Config Integration: Endpoints, timeouts, and auth can be managed via config/saloon.php.
    • Cache Integration: Responses can be cached using Laravel’s cache drivers (e.g., Redis).
    • Queue Integration: Long-running requests (e.g., file uploads) can be queued with Laravel Queues.
    • Validation: Response data can be validated using Laravel’s Validator or Form Requests.

Non-Laravel Stacks:

  • Symfony: Near-perfect fit due to PSR compliance.
  • Lumen: Possible but requires manual setup (no built-in Facade support).
  • Non-PSR Frameworks: Higher effort due to missing DI/HTTP client abstractions.

Migration Path

Phase Actions Tools/Libraries
Assessment Audit existing API clients (Guzzle/cURL/vendor SDKs) for Saloon compatibility. phpstan, psalm
Pilot Project Migrate 1–2 low-risk APIs (e.g., internal tools, non-critical integrations). Saloon’s Connector classes, MockClient
Core Integration Replace Guzzle with Saloon’s PSR-18 client in Laravel’s HTTP stack. symfony/http-client-bundle
Auth Refactor Standardize on Saloon’s Authenticator classes (e.g., BearerToken, OAuth2). league/oauth2-client (if needed)
Testing Overhaul Replace HttpTests with Saloon’s fixtures and MockClient. PestPHP, PHPUnit
Middleware Sync Port Laravel middleware (e.g., ThrottleRequests) to Saloon’s handler stack. Saloon’s Middleware trait
Deprecation Cleanup Remove deprecated methods (e.g., sendAndRetry) and update to v4.0.0. roave/security-advisories

Example Migration:

// Before (Guzzle)
$client = new GuzzleClient();
$response = $client->request('GET', 'https://api.example.com/data', [
    'headers' => ['Authorization' => 'Bearer ' . $token],
]);

// After (Saloon)
class GetDataRequest extends Request {
    protected Method $method = Method::GET;
    protected string $endpoint = 'data';
    protected ?string $authToken = null;

    public function resolveEndpoint(): string {
        return $this->endpoint;
    }

    public function defaultHeaders(): array {
        return ['Authorization' => 'Bearer ' . $this->authToken];
    }
}

$connector = new ExampleConnector();
$response = $connector->send(new GetDataRequest(['authToken' => $token]));

Compatibility

Compatibility Check Status Notes
Laravel 10.x/11.x ✅ Full PSR-18/PSR-7 alignment ensures compatibility.
PHP 8.1–8.5 ✅ Full v3.14.2+ supports PHP 8.5; v4.0.0 may require PHP 8.2+.
Guzzle 7.x ⚠️ Partial Saloon uses Symfony’s client; Guzzle middleware may need adaptation.
OAuth2 Libraries ✅ Full Works with league/oauth2-client or Saloon’s built-in ClientCredentialsGrant.
GraphQL Clients ❌ No Requires custom middleware (e.g., relay-runtime or webonyx/graphql-php).
Legacy SOAP/XML-RPC ⚠️ Partial Possible with custom middleware
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope