saraf/async-request

a wrapper around reactphp/http

0.0.1 2023-11-26 09:55 UTC

This package is auto-updated.

Last update: 2024-04-24 14:14:41 UTC


README

It's just a simple wrapper/helper around reactphp/http library. which creates a better Developer Experience and faster development..

Easy Setup

// initialize basic class
$api = new \Saraf\AsyncRequestJson()
$api->setConfig([
    "baseURL" => "https://jsonplaceholder.typicode.com"
]);

// It will return Promise
$api->post("/todos", [
    'title' => 'learn async-request lib',
    'isDone' => false
])->then(function ($response) {
    // $response contains result, status code, headers and body of that request      
});

Customize Response Handler

This way response body automatically decoded

$api->setResponseHandler(\Saraf\ResponseHandlers\HandlerEnum::Json);