Skip to content

Commit

Permalink
add multiRequest docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SmetDenis committed Jul 31, 2016
1 parent a2764c9 commit 88e5144
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
# JBZoo Http Client [![Build Status](https://travis-ci.org/JBZoo/Http-Client.svg?branch=master)](https://travis-ci.org/JBZoo/Http-Client) [![Coverage Status](https://coveralls.io/repos/github/JBZoo/Http-Client/badge.svg?branch=master)](https://coveralls.io/github/JBZoo/Http-Client?branch=master)

#### Useful wrapper for Guzzle and rmccue/requests
## Useful wrapper for Guzzle and rmccue/requests

[![License](https://poser.pugx.org/JBZoo/Http-Client/license)](https://packagist.org/packages/JBZoo/Http-Client) [![Latest Stable Version](https://poser.pugx.org/JBZoo/Http-Client/v/stable)](https://packagist.org/packages/JBZoo/Http-Client) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/JBZoo/Http-Client/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/JBZoo/Http-Client/?branch=master)

### Install
## Install
```sh
composer require guzzlehttp/guzzle --no-update # Recomended, but not required
composer require jbzoo/http-client
```

### Documentation
## Documentation

"Talk is cheap. Show me the code!" (Linus Torvalds)


#### Simple request
```php
require_once './vendor/autoload.php'; // composer autoload.php

// Get needed classes
use JBZoo\HttpClient\HttpClient;

// Configure client (no options required!)
$client = new HttpClient([
$httpClient = new HttpClient([
'auth' => array( // Simple HTTP auth
'http-user-name',
'http-password'
Expand Down Expand Up @@ -68,6 +71,37 @@ $value = $json->find('key.nested', 'default', 'trim');

```


## Asynchronous requests (multi curl, in parallel)
```php

$httpClient = new HttpClient();

$results = $httpClient->multiRequest(array(
'request_0' => array('http://mockbin.org/request'),
'request_1' => array('http://mockbin.org/request', array(
'args' => array('key' => 'value')
)),
'request_2' => array('http://mockbin.org/request', array(
'method' => 'post',
'args' => array('key' => 'value')
'headers' => array( // You custom headers
'X-Custom-Header' => 42,
),
'timeout' => 10,
'verify' => false,
'exceptions' => false,
'allow_redirects' => true,
'max_redirects' => 10,
'user_agent' => 'JBZoo/Http-Client v1.x-dev'
))
));

$results['request_0']->getBody();
$results['request_1']->getBody();
$results['request_2']->getBody();
```

## Unit tests and check code style
```sh
make
Expand Down

0 comments on commit 88e5144

Please sign in to comment.