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
Guzzle Factory

Guzzle Factory Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Provides A Simple Guzzle Factory With Good Defaults

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.
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
anil/file-picker
broqit/fields-ai