graham-campbell/guzzle-factory
Simple factory for creating Guzzle HTTP clients with sensible defaults. One-liner client creation via GuzzleFactory::make(), with optional config like base_uri. Supports PHP 7.4–8.5 and integrates cleanly in modern PHP/Laravel apps.
Pros:
config/services.php). Aligns with Laravel’s philosophy of explicit, container-managed dependencies.base_uri, timeouts, retries) by 70–80%, improving developer productivity.verify: false flags.Cons:
HttpClient instead).Pool or middleware-based solutions.HttpClient or Psr-18, this package may require refactoring.GuzzleHttp\ClientInterface) for loose coupling.config/services.php for environment-specific settings (e.g., base_uri, timeouts).GuzzleMiddleware::mapResponse) for cross-cutting concerns like logging or auth.graham-campbell/guzzle-factory:^8.0 in composer.json to avoid unexpected updates.Http facade for simple cases.base_uri, timeouts, and retries be defined (e.g., config/services.php, environment variables)?GuzzleFactory)?10K–50K requests.)composer require graham-campbell/guzzle-factory:^8.0.GuzzleMiddleware::mapResponse) for auth, logging, or retries.config/services.php:
'services' => [
'api' => [
'base_uri' => env('API_BASE_URI', 'https://api.example.com'),
'timeout' => env('API_TIMEOUT', 30),
'retries' => [
'max_attempts' => 3,
'backoff' => 100,
'except' => [400, 404],
],
],
],
AppServiceProvider:
public function register(): void
{
$this->app->singleton(GuzzleHttp\ClientInterface::class, function ($app) {
return GuzzleFactory::make(config('services.api'));
});
}
ClientInterface:
// Before
$client = new GuzzleHttp\Client(['base_uri' => 'https://api.example.com']);
// After
public function __construct(private GuzzleHttp\ClientInterface $client) {}
$client = GuzzleFactory::make(
config('services.api'),
TransportSharing::HANDLER_PREFER,
fn (HandlerStack $stack) => $stack->push(/* middleware */)
);
GuzzleFactory or ClientInterface.Http::client() or Http::asForm() to prevent config conflicts.dispatch(new ProcessWebhook($client))).WebhookReceived events using the factory client).GuzzleHttp\Psr7\Response → JsonResource).GuzzleFactory for all external HTTP calls").config/services.php).graham-campbell/guzzle-factory and Guzzle for updates.env() or Laravel’s config_cache).How can I help you explore Laravel packages today?