We are very pleased to announce the initial release of the new HTTP Client extension version 2.0.0.
The extension allows you to perform compose and perform HTTP requests:
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'];
}
This is the most debatable extension we have created, but we believe it is worth to be released.
The extension could be installed using Composer:
composer install yiisoft/yii2-httpclient:~2.0.0
~2.0.0 version constraint is used due to probable backward compatibility break in 2.1.0. Check the Composer documentation on version constraints to learn how that works.
For usage information see official extension documentation.
Please note that yii2-httpclient
is not PSR-7 compatible. It remains an open question for the future 2.1.0 release.