Skip to content

Commit 4906280

Browse files
committed
Updated docs
1 parent 3c816c4 commit 4906280

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Uses [GitHub API v3](http://developer.github.com/v3/). The object API is very si
99

1010
## Features
1111

12-
* Follows PSR-0 conventions and coding standard: autoload friendly
12+
* Follows PSR-4 conventions and coding standard: autoload friendly
1313
* Light and fast thanks to lazy loading of API classes
1414
* Extensively tested and documented
1515

@@ -33,7 +33,9 @@ Then run the following command to require the library:
3333
$ php composer.phar require knplabs/github-api php-http/guzzle6-adapter
3434
```
3535

36-
> `php-github-api` follows the PSR-0 convention names for its classes, which means you can easily integrate `php-github-api` classes loading in your own autoloader.
36+
> `php-github-api` follows the PSR-4 convention names for its classes, which means you can easily integrate `php-github-api` classes loading in your own autoloader.
37+
38+
Why `php-http/guzzle6-adapter`? We are decoupled form any HTTP messaging client with help by [HTTPlug](http://httplug.io/). Read about clients in our [docs](doc/cusomize.md).
3739

3840
## Using Laravel?
3941

doc/customize.md

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
## Customize `php-github-api` and testing
22
[Back to the navigation](README.md)
33

4-
### Configure the http client
54

6-
Wanna change, let's say, the http client User Agent? You need to create a Plugin that modifies the
5+
### Inject a new HTTP client instance
6+
7+
`php-github-api` relies on `php-http/discovery` to find an installed HTTP client. You may specify a HTTP client
8+
yourself by calling `\Github\Client::setHttpClient`. A HTTP client must implement `Http\Client\HttpClient`. A list of
9+
community provided clients is found here: https://packagist.org/providers/php-http/client-implementation
10+
11+
You can inject a HTTP client through `Github\Client#setHttpClient()` method:
12+
13+
```php
14+
$client = new Github\Client();
15+
$client->setHttpClient(new Http\Adapter\Guzzle6\Client());
16+
```
17+
18+
### Configure the HTTP client
19+
20+
Wanna change, let's say, the HTTP client User Agent? You need to create a Plugin that modifies the
721
request. Read more about [HTTPlug plugins here](http://docs.php-http.org/en/latest/plugins/introduction.html#how-it-works).
822

923
```php
@@ -26,34 +40,6 @@ class CustomUserAgentPlugin implements Plugin
2640
$githubClient->addPlugin(new CustomUserAgentPlugin());
2741
```
2842

29-
### Inject a new http client instance
30-
31-
`php-github-api` relies on `php-http/discovery` to find an installed http client. You may specify a HTTP client
32-
yourself by calling `\Github\Client::setHttpClient`. A HTTP client must implement `Http\Client\HttpClient`. A list of
33-
community provided clients is found here: https://packagist.org/providers/php-http/client-implementation
34-
35-
```php
36-
use Github\HttpClient\HttpClient;
37-
38-
// create a custom http client
39-
class MyHttpClient extends HttpClient
40-
{
41-
public function request($url, array $parameters = array(), $httpMethod = 'GET', array $headers = array())
42-
{
43-
// send the request and return the raw response
44-
}
45-
}
46-
```
47-
48-
> Your http client implementation may not extend `Github\HttpClient\HttpClient`, but only implement `Github\HttpClient\HttpClientInterface`.
49-
50-
You can now inject your http client through `Github\Client#setHttpClient()` method:
51-
52-
```php
53-
$client = new Github\Client();
54-
$client->setHttpClient(new Http\Adapter\Guzzle6\Client());
55-
```
56-
5743
### Run Test Suite
5844

5945
The code is unit tested, there are also some functional tests. To run tests on your machine, from a CLI, run

0 commit comments

Comments
 (0)