PHPackages                             tcds-io/php-jackson-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. tcds-io/php-jackson-guzzle

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

tcds-io/php-jackson-guzzle
==========================

A Guzzle plugin that parses request objects into json and response into objects

1.1.1(1mo ago)01.1k↓27.4%MITPHPPHP ^8.4CI passing

Since Jan 14Pushed 1mo agoCompare

[ Source](https://github.com/tcds-io/php-jackson-guzzle)[ Packagist](https://packagist.org/packages/tcds-io/php-jackson-guzzle)[ RSS](/packages/tcds-io-php-jackson-guzzle/feed)WikiDiscussions main Synced yesterday

READMEChangelog (3)Dependencies (6)Versions (6)Used By (0)

PHP Jackson for Guzzle
======================

[](#php-jackson-for-guzzle)

[![PHP Tests](https://github.com/tcds-io/php-jackson-guzzle/actions/workflows/tests.yml/badge.svg)](https://github.com/tcds-io/php-jackson-guzzle/actions/workflows/tests.yml)

Guzzle integration for [tcds-io/php-jackson](https://github.com/tcds-io/php-jackson), a type-safe object mapper inspired by Jackson (Java).

This package provides a typed HTTP client built on top of Guzzle that automatically maps request DTOs into Guzzle options and JSON responses into strongly typed PHP objects, synchronously and asynchronously.

---

Features
--------

[](#features)

- Typed object mapping for HTTP responses
- Request DTO mapping for query params, JSON bodies, and form params
- Full async support with typed promises
- Works with immutable and readonly DTOs
- Keeps the native Guzzle client accessible
- Built on top of php-jackson for consistent serialization rules

---

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

[](#installation)

```
composer require tcds-io/php-jackson-guzzle
```

---

How it works
------------

[](#how-it-works)

1. Create a `JacksonClient` with a native Guzzle client.
2. Pass the expected response DTO class to `get`, `post`, `put`, `patch`, or `request`.
3. Optionally pass request DTOs as query params, JSON body, or form params.
4. Guzzle sends the HTTP request.
5. PHP-Jackson deserializes the JSON response into your expected DTO.

---

Basic usage
-----------

[](#basic-usage)

```
use GuzzleHttp\Client;
use Tcds\Io\Jackson\Guzzle\JacksonClient;

$client = new JacksonClient(
    new Client([
        'base_uri' => 'https://api.example.com',
    ]),
);
```

### Typed GET

[](#typed-get)

```
readonly class Address
{
    public function __construct(
        public string $id,
        public string $street,
        public int $number,
        public bool $main,
    ) {}
}

$address = $client->get(Address::class, '/addresses/aaa');
```

### Typed POST with a JSON body

[](#typed-post-with-a-json-body)

```
readonly class CreateAddress
{
    public function __construct(
        public string $street,
        public int $number,
    ) {}
}

readonly class AddressCreated
{
    public function __construct(public string $id) {}
}

$created = $client->post(
    class: AddressCreated::class,
    uri: '/addresses',
    jsonBody: new CreateAddress(street: 'Ocean Avenue', number: 42),
);
```

You can still pass native Guzzle options when needed:

```
use GuzzleHttp\RequestOptions;

$created = $client->post(
    class: AddressCreated::class,
    uri: '/addresses',
    options: [
        RequestOptions::HEADERS => ['X-Request-ID' => 'abc-123'],
    ],
    jsonBody: new CreateAddress(street: 'Ocean Avenue', number: 42),
);
```

If an option is already present in `options`, the client leaves it untouched.

---

Request data
------------

[](#request-data)

`JacksonClient` can serialize DTOs into the common Guzzle request option buckets:

```
$response = $client->request(
    class: AddressCreated::class,
    method: 'POST',
    uri: '/addresses',
    queryParams: new SearchAddress(street: 'Ocean Avenue'),
    jsonBody: new CreateAddress(street: 'Ocean Avenue', number: 42),
    formParams: new AuditFields(source: 'backoffice'),
);
```

- `queryParams` maps to `RequestOptions::QUERY`
- `jsonBody` maps to `RequestOptions::JSON`
- `formParams` maps to `RequestOptions::FORM_PARAMS`

Pass `null` to omit an option. Empty arrays are treated as intentional payloads and are still passed to Guzzle.

---

Async
-----

[](#async)

```
$address = $client
    ->getAsync(Address::class, '/addresses/aaa')
    ->wait();
```

The async methods return `JacksonPromise`, which decorates Guzzle's promise and maps fulfilled `ResponseInterface` values into your expected DTO.

```
$client
    ->postAsync(
        class: AddressCreated::class,
        uri: '/addresses',
        jsonBody: new CreateAddress(street: 'Ocean Avenue', number: 42),
    )
    ->then(fn(AddressCreated $created) => $created->id)
    ->wait();
```

---

Custom mappers
--------------

[](#custom-mappers)

Pass php-jackson type mappers to the `JacksonClient` constructor when a type needs custom read or write behavior.

```
use GuzzleHttp\Client;
use Tcds\Io\Jackson\Guzzle\JacksonClient;

$client = new JacksonClient(
    guzzle: new Client([
        'base_uri' => 'https://api.example.com',
    ]),
    typeMappers: [
        User::class => [
            'reader' => fn(array $data) => new User(
                name: $data['name'],
                lastName: $data['surname'],
            ),
            'writer' => fn(User $user) => [
                'name' => $user->name,
                'surname' => $user->lastName,
            ],
        ],
    ],
);
```

Please refer to the core mapper documentation for additional configuration options.

---

Development
-----------

[](#development)

```
composer install
vendor/bin/phpunit --testdox
```

---

Related packages
----------------

[](#related-packages)

- Core mapper:
- Symfony integration:
- Laravel integration:

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance89

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

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

Every ~55 days

Total

3

Last Release

58d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8ac1821d71c0ddddcc3494a165dc40cfa3e759a467d8a00956ceeae4b833bb3?d=identicon)[thiagocordeiro](/maintainers/thiagocordeiro)

---

Top Contributors

[![thiagocordeiro](https://avatars.githubusercontent.com/u/1073649?v=4)](https://github.com/thiagocordeiro "thiagocordeiro (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tcds-io-php-jackson-guzzle/health.svg)

```
[![Health](https://phpackages.com/badges/tcds-io-php-jackson-guzzle/health.svg)](https://phpackages.com/packages/tcds-io-php-jackson-guzzle)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[guzzlehttp/guzzle-services

Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.

25711.0M191](/packages/guzzlehttp-guzzle-services)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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