Skip to content

SarafApp/async-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Saraf Async Request (A ReactPHP Wrapper)

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);