HTTP client extension version 2.0.0 released

Yii team relased official HTTP client extension created mainly by Paul Klimov. The extension itself was ready for release long time ago but since there's PSR-7, there were debates about should it be released without it. Finally, it was decided that it's a good idea since, first of all, it's already adopted by many projects, and second, PSR-7 support could be added in further major versions.

Composing and performing HTTP requests looks like the following:

use yii\httpclient\Client;

$client = new Client();
$response = $client->createRequest()
    ->setMethod('post')
    ->setUrl('http://example.com/api/1.0/users')
    ->setData(['name' => 'John Doe', 'email' => 'johndoe@domain.com'])
    ->send();
if ($response->isOk) {
    $newUserId = $response->data['id'];
}

http://www.yiiframework.com/news/100/http-client-extension-version-2-0-0-released/

Comments

Signup in order to comment.