Skip to content

Commit 58c8bc9

Browse files
committed
Changed README file to reflect changes to the class API.
1 parent ab92634 commit 58c8bc9

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

README.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,64 +19,73 @@ $ composer require potherca/flysystem-github
1919
## Usage
2020

2121
The Github adapter can be used *without* credentials to do read-only actions on
22-
public repositories. To save changes or read from private repositories,
23-
credentials are required.
22+
public repositories. To avoid reaching the Github API limit, to save changes, or
23+
to read from private repositories, credentials are required.
2424

25-
To avoid the Github API limit or to save traffic caching can be utilized.
25+
Caching can be utilized to save traffic or to postpone reaching the Github API
26+
limit.
2627

2728
### Basic Usage
2829

2930
```php
30-
use Github\Client;
31+
use Github\Client as GithubClient;
3132
use League\Flysystem\Filesystem;
33+
use Potherca\Flysystem\Github\Client;
3234
use Potherca\Flysystem\Github\GithubAdapter;
35+
use Potherca\Flysystem\Github\Settings;
3336

3437
$project = 'thephpleague/flysystem';
3538

36-
$client = new Client();
37-
$adapter = new GithubAdapter($client, $project);
39+
$settings = new Settings($project);
3840

41+
$client = new Client(new GithubClient(), $settings);
42+
$adapter = new GithubAdapter($client);
3943
$filesystem = new Filesystem($adapter);
4044
```
4145

4246
### Authentication
4347

4448
```php
45-
use Github\Client;
49+
use Github\Client as GithubClient;
4650
use League\Flysystem\Filesystem;
51+
use Potherca\Flysystem\Github\Client;
4752
use Potherca\Flysystem\Github\GithubAdapter;
53+
use Potherca\Flysystem\Github\Settings;
4854

4955
$project = 'thephpleague/flysystem';
56+
$credentials = [Settings::AUTHENTICATE_USING_TOKEN, '83347e315b8bb4790a48ed6953a5ad9e825b4e10'];
57+
// or $authentications = [Settings::AUTHENTICATE_USING_PASSWORD, $username, $password];
58+
59+
$settings = new Settings($project, $credentials);
5060

51-
$client = new Client();
52-
$client->authenticate($token, null, Client::AUTH_HTTP_TOKEN);
53-
// or $client->authenticate($username, $password, Client::AUTH_HTTP_PASSWORD);
54-
$adapter = new GithubAdapter($client, $project);
55-
61+
$client = new Client(new GithubClient(), $settings);
62+
$adapter = new GithubAdapter($client);
5663
$filesystem = new Filesystem($adapter);
5764
```
5865

59-
For full details, see the [php-github-api documentation concerning authentication](https://github.com/KnpLabs/php-github-api/blob/master/doc/security.md).
60-
6166
### Cache Usage
6267

6368
```php
64-
use Github\Client;
69+
use Github\Client as GithubClient;
6570
use Github\HttpClient\CachedHttpClient as CachedClient;
6671
use Github\HttpClient\Cache\FilesystemCache as Cache;
6772
use League\Flysystem\Filesystem;
73+
use Potherca\Flysystem\Github\Client;
6874
use Potherca\Flysystem\Github\GithubAdapter;
75+
use Potherca\Flysystem\Github\Settings;
6976

7077
$project = 'thephpleague/flysystem';
7178

79+
$settings = new Settings($project);
80+
7281
$cache = new Cache('/tmp/github-api-cache')
7382
$cacheClient = new CachedClient();
7483
$cacheClient->setCache($cache);
7584

76-
$client = new Client($cacheClient);
77-
$adapter = new GithubAdapter($client, $project);
78-
85+
$client = new Client($cacheClient, $settings);
86+
$adapter = new GithubAdapter($client);
7987
$filesystem = new Filesystem($adapter);
88+
8089
```
8190

8291
## Testing

0 commit comments

Comments
 (0)