Skip to content

Commit 5dbb5cb

Browse files
authored
minor #1002 Update readme and add example for different http client usage (acrobat)
This PR was merged into the 3.2.x-dev branch. Discussion ---------- I've updated the README a bit so it's more structured and clear also a reference is added to use a different http client (symfony/http-client in this example) Closes #999 Commits ------- 486f0e6 Update readme and add example for different http client usage
2 parents 2e635fc + 486f0e6 commit 5dbb5cb

File tree

2 files changed

+53
-25
lines changed

2 files changed

+53
-25
lines changed

README.md

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# PHP GitHub API
22

3-
[![Build Status](https://travis-ci.org/KnpLabs/php-github-api.svg?branch=master)](https://travis-ci.org/KnpLabs/php-github-api)
3+
![Build Status](https://github.com/KnpLabs/php-github-api/actions/workflows/ci.yml/badge.svg)
44
[![StyleCI](https://styleci.io/repos/3948501/shield?style=flat)](https://styleci.io/repos/3948501)
55
[![Latest Stable Version](https://poser.pugx.org/knplabs/github-api/v/stable)](https://packagist.org/packages/knplabs/github-api)
66
[![Total Downloads](https://poser.pugx.org/knplabs/github-api/downloads)](https://packagist.org/packages/knplabs/github-api)
7-
[![Latest Unstable Version](https://poser.pugx.org/knplabs/github-api/v/unstable)](https://packagist.org/packages/knplabs/github-api)
87
[![Monthly Downloads](https://poser.pugx.org/knplabs/github-api/d/monthly)](https://packagist.org/packages/knplabs/github-api)
98
[![Daily Downloads](https://poser.pugx.org/knplabs/github-api/d/daily)](https://packagist.org/packages/knplabs/github-api)
109

@@ -19,34 +18,46 @@ Uses [GitHub API v3](http://developer.github.com/v3/) & supports [GitHub API v4]
1918

2019
## Requirements
2120

22-
* PHP >= 7.1
21+
* PHP >= 7.2
2322
* A [PSR-17 implementation](https://packagist.org/providers/psr/http-factory-implementation)
2423
* A [PSR-18 implementation](https://packagist.org/providers/psr/http-client-implementation)
2524

26-
## Install
25+
## Quick install
2726

2827
Via [Composer](https://getcomposer.org).
2928

30-
### PHP 7.1+:
29+
This command will get you up and running quickly with a guzzle http client.
3130

3231
```bash
33-
composer require knplabs/github-api:^3.0 php-http/guzzle6-adapter:^2.0.1 http-interop/http-factory-guzzle:^1.0
32+
composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
3433
```
3534

36-
### PHP 7.2+:
35+
## Advanced install
36+
37+
We are decoupled from any HTTP messaging client with help by [HTTPlug](https://httplug.io).
38+
39+
### Using a different http client
3740

3841
```bash
39-
composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
42+
composer require knplabs/github-api:^3.0 symfony/http-client nyholm/psr7
4043
```
4144

42-
### Laravel 6+:
45+
To set up the github client with this http client
4346

44-
```bash
45-
composer require graham-campbell/github:^10.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
47+
```php
48+
use Github\Client;
49+
use Symfony\Component\HttpClient\HttplugClient;
50+
51+
$client = Client::createWithHttpClient(new HttplugClient());
4652
```
4753

48-
We are decoupled from any HTTP messaging client with help by [HTTPlug](http://httplug.io). Read about clients in our [docs](doc/customize.md). [graham-campbell/github](https://github.com/GrahamCampbell/Laravel-GitHub) is by [Graham Campbell](https://github.com/GrahamCampbell).
54+
Read more about [using different clients in our docs](doc/customize.md).
55+
56+
## Framework integrations
57+
58+
### Laravel
4959

60+
To integrate this library in laravel [Graham Campbell](https://github.com/GrahamCampbell) created [graham-campbell/github](https://github.com/GrahamCampbell/Laravel-GitHub). See the [installation instructions](https://github.com/GrahamCampbell/Laravel-GitHub#installation) to get started in laravel.
5061

5162
## Basic usage of `php-github-api` client
5263

@@ -60,7 +71,7 @@ $client = new \Github\Client();
6071
$repositories = $client->api('user')->repositories('ornicar');
6172
```
6273

63-
From `$client` object, you can access to all GitHub.
74+
From `$client` object, you have access to all available GitHub api endpoints.
6475

6576
## Cache usage
6677

@@ -105,18 +116,18 @@ See the [`doc` directory](doc/) for more detailed documentation.
105116
Please read [this post](https://knplabs.com/en/blog/news-for-our-foss-projects-maintenance) first.
106117

107118
This library is maintained by the following people (alphabetically sorted) :
108-
- @acrobat
109-
- @Nyholm
119+
- [@acrobat](https://github.com/acrobat)
120+
- [@Nyholm](https://github.com/Nyholm)
110121

111122
## Contributors
112123

113-
- Thanks to [Thibault Duplessis aka. ornicar](http://github.com/ornicar) for his first version of this library.
114-
- Thanks to [Joseph Bielawski aka. stloyd](http://github.com/stloyd) for his contributions and support.
115-
- Thanks to [noloh](http://github.com/noloh) for his contribution on the Object API.
116-
- Thanks to [bshaffer](http://github.com/bshaffer) for his contribution on the Repo API.
117-
- Thanks to [Rolf van de Krol](http://github.com/rolfvandekrol) for his countless contributions.
118-
- Thanks to [Nicolas Pastorino](http://github.com/jeanvoye) for his contribution on the Pull Request API.
119-
- Thanks to [Edoardo Rivello](http://github.com/erivello) for his contribution on the Gists API.
124+
- Thanks to [Thibault Duplessis aka. ornicar](https://github.com/ornicar) for his first version of this library.
125+
- Thanks to [Joseph Bielawski aka. stloyd](https://github.com/stloyd) for his contributions and support.
126+
- Thanks to [noloh](https://github.com/noloh) for his contribution on the Object API.
127+
- Thanks to [bshaffer](https://github.com/bshaffer) for his contribution on the Repo API.
128+
- Thanks to [Rolf van de Krol](https://github.com/rolfvandekrol) for his countless contributions.
129+
- Thanks to [Nicolas Pastorino](https://github.com/jeanvoye) for his contribution on the Pull Request API.
130+
- Thanks to [Edoardo Rivello](https://github.com/erivello) for his contribution on the Gists API.
120131
- Thanks to [Miguel Piedrafita](https://github.com/m1guelpf) for his contribution to the v4 & Apps API.
121132
- Thanks to [Emre DEGER](https://github.com/lexor) for his contribution to the Actions API.
122133

doc/customize.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,33 @@
44

55
### Inject a new HTTP client instance
66

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
7+
`php-github-api` relies on `php-http/discovery` to find an installed HTTP client. You may specify an HTTP client
8+
yourself by calling `\Github\Client::setHttpClient`. An HTTP client must implement `Http\Client\HttpClient`. A list of
99
community provided clients is found here: https://packagist.org/providers/php-http/client-implementation
1010

11-
You can inject a HTTP client through the `Github\Client` constructor:
11+
You can inject an HTTP client through the `Github\Client` constructor:
1212

1313
```php
1414
$client = Github\Client::createWithHttpClient(new Http\Adapter\Guzzle6\Client());
1515
```
1616

17+
#### Example
18+
19+
To use the symfony http client
20+
21+
```bash
22+
composer require symfony/http-client nyholm/psr7
23+
```
24+
25+
To set up the github client with this http client
26+
27+
```php
28+
use Github\Client;
29+
use Symfony\Component\HttpClient\HttplugClient;
30+
31+
$client = Client::createWithHttpClient(new HttplugClient());
32+
```
33+
1734
### Configure the HTTP client
1835

1936
Wanna change, let's say, the HTTP client User Agent? You need to create a Plugin that modifies the

0 commit comments

Comments
 (0)