Download the PHP package nimbly/shuttle without Composer
On this page you can find all versions of the php package nimbly/shuttle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nimbly/shuttle
More information about nimbly/shuttle
Files in nimbly/shuttle
Informations about the package shuttle
Shuttle
A simple PSR-18 HTTP client library.
Installation
Features
- Responses create php://temp response body stream and swap to disk when necessary.
- cURL (default) and Stream Context handlers supported.
- Middleware support out of the box.
- Easy body transformations when creating requests with JsonBody, FormBody, and XmlBody helper classes.
Not features
- Asynchronous calls.
Making requests: The easy way
The quickest and easiest way to begin making requests in Shuttle is to use the HTTP method name:
Shuttle has built-in methods to support the major HTTP verbs: get, post, put, patch, delete, head, and options. However, you can make any HTTP verb request using the request method directly.
Handling responses
Responses in Shuttle implement PSR-7 ResponseInterface and as such are streamable resources.
Handling failed requests
Shuttle will throw a by default if the request failed. This includes things like host name not found, connection timeouts, etc.
Responses with HTTP 4xx or 5xx status codes will not throw an exception and must be handled properly within your business logic.
Making requests: The PSR-7 way
If code reusability and portability is your thing, future proof your code by making requests the PSR-7 way. Remember, PSR-7 stipulates that Request and Response messages be immutable.
Request bodies
An easy way to submit data with your request is to use the helper classes. These classes will automatically transform the data, convert to a BufferStream, and set a default Content-Type header on the request.
The request bodies support are:
JsonBody
Converts an associative array into JSON, setsContent-Type
header toapplication/json
.FormBody
Converts an associative array into a query string, setsContent-Type
header toapplication/x-www-form-urlencoded
.XmlBody
Does no conversion of data, setsContent-Type
header toapplication/xml
.
To submit a JSON payload with a request:
All versions of shuttle with dependencies
ext-json Version *
psr/http-client Version ^1.0
nimbly/capsule Version ^2.0