A guzzle wrapper with typehints and syntactic sugar.
johnathan-smith/xttp is a Laravel package for a guzzle wrapper with typehints and syntactic sugar..
It currently has 1 GitHub stars and 13 downloads on Packagist (latest version 1.0.3).
Install it with composer require johnathan-smith/xttp.
Discover more Laravel packages by johnathan-smith
or browse all Laravel packages to compare alternatives.
Last updated

Regular use is simple:
<?php
use JohnathanSmith\Xttp\Xttp;
/** @var \JohnathanSmith\Xttp\XttpResponseWrapper $xttpResponse */
$xttpResponse = Xttp::post('https://johnathansmith.com', ['form_params' => ['foo' => 'bar'], 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded']]);
// You may also do get, put, patch, delete.
There is also a package for Laravel.
After making the request you will get an instance of XttpResponse. This
has a lot of syntactic sugar, for example:
One of the ways that this package shines is that it is set up to be very friendly with Unit testing. You can also easily create a longer version from above with an large amount of granular detail. You can do this on XttpPending the object. With this we can:
<?php
use JohnathanSmith\Xttp\XttpPending;
$response = XttpPending::new()
->setUrl(// url)
->setMethod(// method)
->withHeaders(['X-Foo' => 'Bar'])
->asJson()
->send();
Xttp was inspired by Adam Wathan's zttp. A special thanks to the maintainers of Guzzle.