Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blueridgemountains1/xttp
A guzzle wrapper with typehints and syntactic sugar in PHP
https://github.com/blueridgemountains1/xttp
guzzle guzzle-middleware guzzlehttp laravel php
Last synced: 2 days ago
JSON representation
A guzzle wrapper with typehints and syntactic sugar in PHP
- Host: GitHub
- URL: https://github.com/blueridgemountains1/xttp
- Owner: blueridgemountains1
- Created: 2020-02-11T01:17:30.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-04T10:33:46.000Z (over 3 years ago)
- Last Synced: 2025-01-15T21:14:23.701Z (6 days ago)
- Topics: guzzle, guzzle-middleware, guzzlehttp, laravel, php
- Language: PHP
- Homepage: https://johnathansmith.com/xttp/
- Size: 86.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# xttp
![](https://johnathansmith.com/uploads/xttp-logo-white.png)
### A guzzle wrapper with typehints and syntactic sugar.
Regular use is simple:
```php
['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](https://github.com/jr-smith/xttp-laravel).
After making the request you will get an instance of `XttpResponse`. This
has a lot of syntactic sugar, for example:
- Getting header/s
- Getting response status and info
- Returning JSON or body
- Getting URL
- CookiesOne 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:
- Add Cookies/Headers/Options
- Add or prepend Request/Response/Retry/Other middleware
- Guzzle History and/or Mock handlers
- Authorization
- Guzzle Client Construction```php
setUrl(// url)
->setMethod(// method)
->withHeaders(['X-Foo' => 'Bar'])
->asJson()
->send();
```Xttp was inspired by Adam Wathan's [zttp](https://github.com/kitetail/zttp). A special thanks to the maintainers of Guzzle.