📜 ⬆️ ⬇️

The official HTTP client for Yii 2 has been released

The Yii team has released the official HTTP client extension. Written almost entirely by Pavel Klimov. Until recently, it was not tagged as a release due to incompatibility with PSR-7, although it has already been used a lot. After much discussion, it was decided to release without PSR-7. It may be returned to 2.1.x.


Performing an HTTP request looks like this:


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']; } 

https://github.com/yiisoft/yii2-httpclient


')

Source: https://habr.com/ru/post/304584/


All Articles