Download the PHP package tcds-io/php-jackson-guzzle without Composer
On this page you can find all versions of the php package tcds-io/php-jackson-guzzle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tcds-io/php-jackson-guzzle
More information about tcds-io/php-jackson-guzzle
Files in tcds-io/php-jackson-guzzle
Package php-jackson-guzzle
Short Description A Guzzle plugin that parses request objects into json and response into objects
License MIT
Informations about the package php-jackson-guzzle
PHP Jackson for Guzzle
Guzzle integration for 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
- 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
How it works
- Create a
JacksonClientwith a native Guzzle client. - Pass the expected response DTO class to
get,post,put,patch, orrequest. - Optionally pass request DTOs as query params, JSON body, or form params.
- Guzzle sends the HTTP request.
- PHP-Jackson deserializes the JSON response into your expected DTO.
Basic usage
Typed GET
Typed POST with a JSON body
You can still pass native Guzzle options when needed:
If an option is already present in options, the client leaves it untouched.
Request data
JacksonClient can serialize DTOs into the common Guzzle request option buckets:
queryParamsmaps toRequestOptions::QUERYjsonBodymaps toRequestOptions::JSONformParamsmaps toRequestOptions::FORM_PARAMS
Pass null to omit an option. Empty arrays are treated as intentional payloads and are still passed to Guzzle.
Async
The async methods return JacksonPromise, which decorates Guzzle's promise and maps fulfilled ResponseInterface values into your expected DTO.
Custom mappers
Pass php-jackson type mappers to the JacksonClient constructor when a type needs custom read or write behavior.
Please refer to the core mapper documentation for additional configuration options.
Development
Related packages
- Core mapper: https://github.com/tcds-io/php-jackson
- Symfony integration: https://github.com/tcds-io/php-jackson-symfony
- Laravel integration: https://github.com/tcds-io/php-jackson-laravel