PHPackages                             larafony/http-guzzle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. larafony/http-guzzle

ActiveLibrary[HTTP &amp; Networking](/categories/http)

larafony/http-guzzle
====================

Guzzle HTTP client bridge for Larafony Framework

1.0.0(3mo ago)01MITPHPPHP ^8.5

Since Jan 28Pushed 3mo agoCompare

[ Source](https://github.com/DJWeb-Damian-Jozwiak/larafony-http-guzzle)[ Packagist](https://packagist.org/packages/larafony/http-guzzle)[ RSS](/packages/larafony-http-guzzle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Larafony Guzzle HTTP Bridge
===========================

[](#larafony-guzzle-http-bridge)

This package provides integration between Larafony Framework and [Guzzle](https://docs.guzzlephp.org/) - the most popular PHP HTTP client.

Installation
------------

[](#installation)

```
composer require larafony/http-guzzle
```

Usage
-----

[](#usage)

Register the service provider in your `bootstrap.php`:

```
use Larafony\Http\Guzzle\ServiceProviders\GuzzleServiceProvider;

$app->withServiceProviders([
    GuzzleServiceProvider::class
]);
```

### Basic operations

[](#basic-operations)

```
use Larafony\Framework\Validation\Attributes\Email;
use Larafony\Framework\Validation\Attributes\IsValidated;
use Larafony\Framework\Validation\Attributes\MinLength;
use Larafony\Framework\Validation\FormRequest;
use Larafony\Framework\Web\Config;
use Larafony\Http\Guzzle\GuzzleHttpClient;
use Larafony\Framework\Web\Application;
use Larafony\Framework\Web\Controller;
use Larafony\Framework\Routing\Advanced\Attributes\Route;
use Larafony\Framework\Http\Factories\ResponseFactory;
use Larafony\Http\Guzzle\GuzzleHttpClientFactory;
use Psr\Http\Message\ResponseInterface;

final class UserRequest extends FormRequest
{
    //properties are automatically injected from the request
    #[IsValidated]
    #[MinLength(3)]
    public protected(set) string $firstName;
    #[IsValidated]
    #[MinLength(3)]
    public protected(set) string $lastName;
    #[IsValidated]
    #[Email]
    public protected(set) string $email;

    /**
     * @return array
     */
    public function toArray(): array
    {
        return [
            'firstName' => $this->firstName,
            'lastName' => $this->lastName,
            'email' => $this->email,
        ];
    }
}

final class ApiController extends Controller
{
    #[Route('/fetch-users')]
    public function fetchUsers(GuzzleHttpClient $client): \Psr\Http\Message\ResponseInterface
    {
        // Simple GET request (use guzzle client directly)
        $response = $client->getGuzzle()->get('https://api.example.com/users') |> $this->decodeResponse(...);

        return new ResponseFactory()->createJsonResponse($response);
    }

    #[Route('/update-users', methods: ['PUT', 'POST'])]
    public function updateUsers(GuzzleHttpClient $client, UserRequest $request): ResponseInterface
    {
        //use bridge facade
        $response = $client->post('https://api.example.com/users', [
            'json' => $request->toArray(),
        ]) |> $this->decodeResponse(...);

        return new ResponseFactory()->createJsonResponse($response);
    }

    #[Route('/authorized')]
    public function authorized(): ResponseInterface
    {
        $token = Config::get('api.token');
        $client = GuzzleHttpClientFactory::withBearerToken($token);
        $response = $client->get('https://api.example.com/data') |> $this->decodeResponse(...);

        return new ResponseFactory()->createJsonResponse($response);
    }

    private function decodeResponse (ResponseInterface $response): array
    {
        return json_decode($response->getBody()->getContents(), associative: true, flags: JSON_THROW_ON_ERROR);
    }
}
```

### PSR-18 Compatibility

[](#psr-18-compatibility)

The Guzzle bridge implements PSR-18 `ClientInterface`, making it a drop-in replacement for Larafony's built-in HTTP client:

```
use Psr\Http\Client\ClientInterface;

// Works with any PSR-18 compatible code
function fetchData(ClientInterface $client): array
{
    $response = $client->sendRequest($request);
    return json_decode($response->getBody()->getContents(), true);
}
```

### Advanced Features

[](#advanced-features)

```
// Concurrent requests
$promises = [
    'users' => $client->getAsync('https://api.example.com/users'),
    'posts' => $client->getAsync('https://api.example.com/posts'),
];
$results = \GuzzleHttp\Promise\Utils::unwrap($promises);

// Retry middleware
$client = $container->get(GuzzleHttpClient::class);
$client->withMiddleware(new RetryMiddleware(maxRetries: 3));

// Upload files
$response = $client->post('https://api.example.com/upload', [
    'multipart' => [
        [
            'name' => 'file',
            'contents' => fopen('/path/to/file.pdf', 'r'),
        ],
    ],
]);
```

Features
--------

[](#features)

- **PSR-18 compatible** - Implements `ClientInterface`
- **Full Guzzle API** - Access all Guzzle features
- **Async requests** - Concurrent HTTP requests with promises
- **Middleware system** - Retry, logging, caching
- **File uploads** - Multipart form data support
- **Streaming** - Handle large responses efficiently

Why use this bridge?
--------------------

[](#why-use-this-bridge)

While Larafony includes a built-in PSR-18 HTTP client, Guzzle offers:

- Async/concurrent request support
- Rich middleware ecosystem
- Automatic retries and error handling
- Cookie jar management
- Battle-tested codebase

Learn How It's Built - From Scratch
-----------------------------------

[](#learn-how-its-built---from-scratch)

Interested in **how Larafony is built step by step?**

Check out my full PHP 8.5 course, where I explain everything from architecture to implementation - no magic, just clean code.

Get it now at [masterphp.eu](https://masterphp.eu)

License
-------

[](#license)

MIT License. Larafony-http-guzzle is open-sourced software licensed under the [MIT license](https://opensource.org/license/MIT).

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance81

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

101d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/41979fa3adf74e308157185e30a99c93795d8bb8c33f35dbcef030cb3c9865c2?d=identicon)[damek24](/maintainers/damek24)

---

Top Contributors

[![damek24](https://avatars.githubusercontent.com/u/11960180?v=4)](https://github.com/damek24 "damek24 (1 commits)")

---

Tags

httpclientpsr-18Guzzlelarafony

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/larafony-http-guzzle/health.svg)

```
[![Health](https://phpackages.com/badges/larafony-http-guzzle/health.svg)](https://phpackages.com/packages/larafony-http-guzzle)
```

###  Alternatives

[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

11259.2k](/packages/e-moe-guzzle6-bundle)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[amphp/http-client-guzzle-adapter

Guzzle adapter for Amp's HTTP client.

1523.6k1](/packages/amphp-http-client-guzzle-adapter)[opgg/riotquest

RiotQuest, PHP RiotAPI client library that focused on multi request from OP.GG

172.6k](/packages/opgg-riotquest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
