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

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 provides a simple factory for creating Guzzle HTTP clients with sensible defaults. It standardizes client setup while allowing configuration overrides such as base_uri.

  • Good defaults for quick client creation
  • Custom handler stacks via callback
  • Optional transport sharing, disabled by default
  • PHP 7.4–8.5 compatibility
  • Install via Composer: ^8.0
Frequently asked questions about Guzzle Factory
How do I install GuzzleFactory in a Laravel project?
Run `composer require graham-campbell/guzzle-factory` to install. No additional Laravel-specific setup is needed beyond requiring the package. It works with Laravel 9–11 and PHP 7.4–8.5 out of the box.
Can I use GuzzleFactory with Laravel’s service container?
Yes. Bind it as a singleton in your `AppServiceProvider` or resolve dynamically via `app(GuzzleFactory::class)`. This enables dependency injection into controllers, jobs, or commands for cleaner architecture.
What are the default security settings for Guzzle clients created by this factory?
The factory enforces TLS 1.2+ by default and includes sensible retry policies. You can override these via config or factory arguments, but the defaults align with PCI DSS, GDPR, and HIPAA compliance.
How do I configure multiple API clients (e.g., Stripe, PayPal) with different settings?
Centralize configurations in `config/services.php` and pass the relevant config array to `GuzzleFactory::make()`. For example, use `'stripe' => ['base_uri' => 'https://api.stripe.com', 'auth' => [env('STRIPE_KEY'), '']]` for Stripe-specific clients.
Does GuzzleFactory support custom middleware like logging or caching?
Yes. Use `makeWithHandler()` (v4.2+) to inject custom middleware stacks. For example, add Laravel’s caching middleware or logging middleware by passing a closure that modifies the `HandlerStack`.
Is GuzzleFactory compatible with Laravel’s HTTP client facade or caching middleware?
No, it’s not a drop-in replacement for Laravel’s HTTP facade. However, you can integrate it with Laravel’s caching middleware by using `makeWithHandler()` to inject the caching stack manually.
How do I mock GuzzleFactory in PHPUnit tests?
Use Laravel’s service container to mock the factory: `$this->app->instance(GuzzleFactory::class, Mockery::mock(GuzzleFactory::class));`. This allows you to stub responses or verify client configurations in unit tests.
What Laravel versions and PHP versions does GuzzleFactory support?
GuzzleFactory supports PHP 7.4–8.5 and integrates seamlessly with Laravel 9–11. It’s compatible with Laravel’s default Guzzle 7+ and avoids version conflicts.
Does GuzzleFactory add significant overhead to my application?
No, the package adds minimal overhead (~1MB for Guzzle) and is optimized for simplicity. It’s ideal for most Laravel apps, though high-performance scenarios (e.g., >10K requests/sec) may require raw Guzzle or Symfony’s HttpClient.
What if I need connection pooling or gRPC support?
GuzzleFactory doesn’t support connection pooling or gRPC out of the box. For these use cases, consider using raw Guzzle middleware or Symfony’s HttpClient, which offers more advanced features like connection pooling.
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.
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
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai