Download the PHP package flikson/laravel-service-client without Composer
On this page you can find all versions of the php package flikson/laravel-service-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download flikson/laravel-service-client
More information about flikson/laravel-service-client
Files in flikson/laravel-service-client
Package laravel-service-client
Short Description HTTP client package for Laravel with retry, multi-host, circuit breaker, and async support
License BSD-3-Clause
Informations about the package laravel-service-client
Service Client Bundle
π Language: Π ΡΡΡΠΊΠΈΠΉ
Laravel-focused HTTP client with retry, multi-host failover, circuit breaker, and async support via PHP Fibers.
Features
- Retry with exponential backoff β configurable delay, jitter, and status codes
- Multi-host strategies β failover, round-robin, parallel
- Circuit breaker β automatic failure detection and recovery
- Async via Fibers β non-blocking requests with Revolt event loop
- Middleware pipeline β extensible request/response processing
- Multiple auth methods β Bearer, API Key, Basic
- Typed requests β ISP-based interfaces with response mapping
Requirements
- PHP 8.4+
- Guzzle 7.9+
- Illuminate Support/Contracts 11+ | 12+
Installation
Laravel
Laravel package discovery is supported via extra.laravel.providers.
Publish config:
The published config file path:
If package discovery is disabled, register provider manually in config/app.php:
Resolve client from container:
Configuration
Usage
Typed Request (Recommended)
POST Request with Body
Request Builder (Quick Requests)
The builder is immutable β each method returns a new instance:
Async Requests
Callbacks
Error Response Callbacks
Use onErrorResponse() for handling 4xx/5xx responses separately from network errors:
then($onSuccess)β called for 2xx responsesonErrorResponse($callback)β called for 4xx/5xx responses with bodythen(null, $onError)β called for network errors (timeout, connection failed)
Request Interfaces (ISP)
| Interface | Purpose |
|---|---|
RequestInterface |
Base request (service, method, uri, headers, query, body) |
AuthRequiredInterface |
Marker: request requires authentication |
ConfigurableRequestInterface |
Override timeout/retry for specific request |
MappableRequestInterface<T> |
Custom response mapping to type T |
ErrorMappableRequestInterface<E> |
Custom error response (4xx/5xx) mapping to type E |
Also available: BaseRequest β base class with default implementations for getHeaders(), getQuery(), getBody().
Handling Error Responses
Implement ErrorMappableRequestInterface for custom mapping of error responses (4xx/5xx):
Multi-Host Strategies
Failover
Tries hosts in order, switches on 5xx or network error:
Round-Robin
Distributes load across hosts:
Parallel
Sends to all hosts, returns first successful response:
Retry Configuration
Authentication Types
Bearer Token
API Key
Basic Auth
Middleware Pipeline
Requests pass through middleware chain in priority order:
| Priority | Middleware | Purpose |
|---|---|---|
| 100 | AuthMiddleware | Adds Authorization header |
| 90 | RetryMiddleware | Retries with exponential backoff |
| 80 | LoggingMiddleware | Logs requests/responses |
| 60 | CircuitBreakerMiddleware | Cascade failure protection |
| 10 | MultiHostMiddleware | Failover/round-robin/parallel |
More details: docs/en/middleware.md
Documentation
- Configuration
- Laravel Integration
- Middleware
- Multi-Host
License
BSD-3-Clause
All versions of laravel-service-client with dependencies
guzzlehttp/guzzle Version ^7.9
guzzlehttp/promises Version ^2.0
illuminate/contracts Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
psr/log Version ^3.0
revolt/event-loop Version ^1.0