A small http client for trail
- PHP 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| .editorconfig | ||
| .gitignore | ||
| composer.json | ||
| LICENSE | ||
| README.md | ||
trail-http
A small http client for trail
install
composer require trail/http
Requires curl which like... everyone has
use
use Trail\Http\Http;
public function __construct(private Http $http) {}
$reply = $this->http->get('https://api.example.com/things', headers: ['Accept' => 'application/json']);
$reply->status;
$reply->header('etag');
$reply->json();
$reply->isOk();
$this->http->post($url, json: ['name' => 'cat']);
$this->http->post($url, body: ['name' => 'cat']);
$this->http->put($url, body: fopen($path, 'rb'));
$this->http->get($url, saveTo: '/tmp/big.zip', maxBytes: 50_000_000);
$this->http->get($url, redirects: 3, timeout: 10);