Download the PHP package olivermack/duzzle without Composer

On this page you can find all versions of the php package olivermack/duzzle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package duzzle

Duzzle: An opinionated, DTO-centric Guzzle HTTP Wrapper

build codecov

Duzzle (_DTOs + Guzzle_) is a lightweight extension on top of Guzzle designed to seamlessly integrate DTO serialization and validation workflows into your HTTP client calls. It leverages the Symfony Serializer and (optionally) the Symfony Validator to transform your domain objects (DTOs) into request payloads, validate them before dispatch, and then deserialize responses back into strongly typed objects—enabling a clean, high-level API around Guzzle's powerful HTTP capabilities.

If you’re seeking a straightforward, “DTO-first” approach to RESTful interactions without manually handling JSON or validation rules, Duzzle aims to provide an easy and extensible solution.

Installation

Install the package via composer

Background

Duzzle was created as a proof of concept to show how/if a single API client implementation can reduce complexity in a domain application which deals with multiple different remote APIs.

Because Guzzle is a pretty well known and widely used API client in the PHP world Duzzle was built as a "wrapper" for Guzzle right from the start - hence the weird name ;).

Duzzle works with output and input definitions for any particular API call.

In order to add an extra guard for the consumption of remote APIs, Duzzle allows the validation of the input before sending it to the remote API as well as validating the output of the API to ensure that the API-consumer can deal with unexpected changes or invalid data.

Usage

First, create an instance of Duzzle via the DuzzleBuilder:

With the instance you can perform your requests. To make the usage easier Duzzle only provides a single request() method, following the signature that Guzzle's request() provides.

To access the data which was handled by Duzzle's middlewares you need to call getDuzzleResult() on the response.

DTO (De)Serialization

To deserialize the response into your domain specific DTO, you need to define the class as POPO (plain old php object) and tell the client to use it as output type:

To send an instance of a DTO to the API, you need to provide the instance as input:

Custom Serializer

The default serializer setup shipped with Duzzle is configured for the most common JSON API examples. However, if you need to use your own serializer stack you can provide it in the builder:

Validation

To use the (optional) validation capabilities you need to install the required symfony/validator package.

Now, when you create your Duzzle instance, you can ask the builder to set up the default validation behavior for you.

Validation Strategies

Duzzle works with different "Strategies" to determine how the validation result should affect the behavior of the API client.

ℹ️ Without specifying a strategy, no validation will actually happen even if you told the builder to use the default validator!

The following strategies are shipped with Duzzle:

The informative strategy expects a PSR-3 logger. You need to pass one in the builder to get any effective output using $builder->withLogger($myLogger).

Validation constraints

With the default validator defined you can use PHP attributes to define your rules on the DTO class:

To validate the input, make sure your Duzzle instance is equipped with a default input_validation or define it per request like so:

For a working example check out examples/02-validation-json-api.php

Todos


All versions of duzzle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
guzzlehttp/guzzle Version ^7.8
symfony/serializer Version ^7.2
symfony/property-info Version ^7.2
symfony/property-access Version ^7.2
psr/log Version ^3.0
phpdocumentor/reflection-docblock Version ^5.6
phpstan/phpdoc-parser Version ^1.0|^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package olivermack/duzzle contains the following files

Loading the files please wait ...