Download the PHP package diginedbv/unirest-php without Composer
On this page you can find all versions of the php package diginedbv/unirest-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package unirest-php
To the community: At this time Unirest-PHP only support syncronous requests, and I would really love to implement asynchronous support. If you guys have any feedback or ideas please comment on issue #23.
Unirest for PHP 
Unirest is a set of lightweight HTTP libraries available in multiple languages, ideal for most applications:
- Make
GET,POST,PUT,PATCH,DELETErequests - It supports form parameters, file uploads and custom body entities
- Supports gzip
- Supports Basic Authentication natively
- Customizable timeout
- Customizable default headers for every request (DRY)
- Automatic JSON parsing into a native object for JSON responses
Created with love by thefosk @ mashape.com
Install with Composer
If you're using Composer to manage dependencies, you can add Unirest with it.
Install source from GitHub
Unirest-PHP requires PHP v5.3+. Download the PHP library from Github, and require in your script like so:
To install the source code:
And include it in your scripts:
Creating Request
So you're probably wondering how using Unirest makes creating requests in PHP easier, let's look at a working example:
File Uploads
To upload files in a multipart form representation use the return value of Unirest::file($path) as the value of a parameter:
Custom Entity Body
Sending a custom body such as a JSON Object rather than a string or form style parameters we utilize json_encode for the body:
Basic Authentication
Authenticating the request with basic authentication can be done by providing the username and password arguments:
Request
url- Endpoint, address, or uri to be acted upon and requested information from.headers- Request Headers as associative array or objectbody- Request Body as associative array or objectusername- Basic Authentication usernamepassword- Basic Authentication password
Response
Upon recieving a response Unirest returns the result in the form of an Object, this object should always have the same keys for each language regarding to the response details.
code- HTTP Response Status Code (Example200)headers- HTTP Response Headersbody- Parsed response body where applicable, for example JSON responses are parsed to Objects / Associative Arrays.raw_body- Un-parsed response body
Advanced Configuration
You can set some advanced configuration to tune Unirest-PHP:
Timeout
You can set a custom timeout value (in seconds):
Default Request Headers
You can set default headers that will be sent on every request:
You can clear the default headers anytime with:
SSL validation
You can explicitly enable or disable SSL certificate validation when consuming an SSL protected endpoint:
By default is true.
All versions of unirest-php with dependencies
ext-curl Version *
ext-json Version *