cspray/http-request-builder

A fluent API to build Requests for use with amphp/http-client

1.3.0 2023-04-13 14:18 UTC

This package is auto-updated.

Last update: 2024-11-04 13:55:44 UTC


README

A library to fluently create amphp/http-client Request objects.

Installation

composer require cspray/http-request-builder

Usage

This library has 1 focused purpose; easily create Requests.

<?php declare(strict_types=1);

use Cspray\HttpRequestBuilder\RequestBuilder;

$request = RequestBuilder::withJsonBody([
    'three words' => 'enthusiastic,positivity,clashing'
])->post('https://api.example.com');

\Amp\Http\Client\HttpClientBuilder::buildDefault()->request($request);