Weave 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

Guzzle Factory Laravel Package

graham-campbell/guzzle-factory

A simple Guzzle factory with sensible defaults for PHP 7.4–8.5. Create ready-to-use clients in one call, customize the handler stack, and optionally enable best-effort transport sharing for handler-lifetime reuse.

View on GitHub
Deep Wiki
Context7

Guzzle Factory

Guzzle Factory was created by, and is maintained by Graham Campbell, and provides a simple Guzzle factory, with good defaults. Feel free to check out the change log, releases, security policy, license, code of conduct, and contribution guidelines.

Banner

Installation

This version requires PHP 7.4-8.5.

To get the latest version, simply require the project using Composer:

$ composer require "graham-campbell/guzzle-factory:^8.0"

Usage

<?php

use GrahamCampbell\GuzzleFactory\GuzzleFactory;

$client = GuzzleFactory::make(['base_uri' => 'https://example.com']);

Customizing The Handler Stack

<?php

use GrahamCampbell\GuzzleFactory\GuzzleFactory;
use GuzzleHttp\HandlerStack;

$client = GuzzleFactory::make(
    ['base_uri' => 'https://example.com'],
    null,
    static function (HandlerStack $stack): void {
        $stack->push(static fn (callable $handler): callable => $handler, 'custom');
    },
);

Transport Sharing

Transport sharing is disabled by default. If you need best-effort handler-lifetime transport sharing, pass the sharing mode as the second argument:

<?php

use GrahamCampbell\GuzzleFactory\GuzzleFactory;
use GuzzleHttp\TransportSharing;

$client = GuzzleFactory::make(
    ['base_uri' => 'https://example.com'],
    TransportSharing::HANDLER_PREFER,
);

Security

If you discover a security vulnerability within this package, please send an email to [email protected]. All security vulnerabilities will be promptly addressed. You may view our full security policy here.

License

Guzzle Factory is licensed under The MIT License (MIT).

For Enterprise

Available as part of the Tidelift Subscription

The maintainers of graham-campbell/guzzle-factory and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

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.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core