|
| 1 | +# Flysystem Adapter for Github |
| 2 | + |
| 3 | +[](https://github.com/potherca/flysystem-github/releases) |
| 4 | +[](LICENSE.md) |
| 5 | +[](https://travis-ci.org/potherca/flysystem-github) |
| 6 | +[](https://scrutinizer-ci.com/g/potherca/flysystem-github/code-structure) |
| 7 | +[](https://scrutinizer-ci.com/g/potherca/flysystem-github) |
| 8 | +[](https://packagist.org/packages/potherca/flysystem-github) |
| 9 | + |
| 10 | + |
| 11 | +## Install |
| 12 | + |
| 13 | +Via Composer |
| 14 | + |
| 15 | +``` bash |
| 16 | +$ composer require potherca/flysystem-github |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +The Github adapter can be used *without* credentials to do read-only actions on |
| 22 | +public repositories. To avoid reaching the Github API limit, to save changes, or |
| 23 | +to read from private repositories, credentials are required. |
| 24 | + |
| 25 | +Caching can be utilized to save traffic or to postpone reaching the Github API |
| 26 | +limit. |
| 27 | + |
| 28 | +### Basic Usage |
| 29 | + |
| 30 | +```php |
| 31 | +use Github\Client as GithubClient; |
| 32 | +use League\Flysystem\Filesystem; |
| 33 | +use Potherca\Flysystem\Github\Client; |
| 34 | +use Potherca\Flysystem\Github\GithubAdapter; |
| 35 | +use Potherca\Flysystem\Github\Settings; |
| 36 | + |
| 37 | +$project = 'thephpleague/flysystem'; |
| 38 | + |
| 39 | +$settings = new Settings($project); |
| 40 | + |
| 41 | +$client = new Client(new GithubClient(), $settings); |
| 42 | +$adapter = new GithubAdapter($client); |
| 43 | +$filesystem = new Filesystem($adapter); |
| 44 | +``` |
| 45 | + |
| 46 | +### Authentication |
| 47 | + |
| 48 | +```php |
| 49 | +use Github\Client as GithubClient; |
| 50 | +use League\Flysystem\Filesystem; |
| 51 | +use Potherca\Flysystem\Github\Client; |
| 52 | +use Potherca\Flysystem\Github\GithubAdapter; |
| 53 | +use Potherca\Flysystem\Github\Settings; |
| 54 | + |
| 55 | +$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); |
| 60 | + |
| 61 | +$client = new Client(new GithubClient(), $settings); |
| 62 | +$adapter = new GithubAdapter($client); |
| 63 | +$filesystem = new Filesystem($adapter); |
| 64 | +``` |
| 65 | + |
| 66 | +### Cache Usage |
| 67 | + |
| 68 | +```php |
| 69 | +use Github\Client as GithubClient; |
| 70 | +use Github\HttpClient\CachedHttpClient as CachedClient; |
| 71 | +use Github\HttpClient\Cache\FilesystemCache as Cache; |
| 72 | +use League\Flysystem\Filesystem; |
| 73 | +use Potherca\Flysystem\Github\Client; |
| 74 | +use Potherca\Flysystem\Github\GithubAdapter; |
| 75 | +use Potherca\Flysystem\Github\Settings; |
| 76 | + |
| 77 | +$project = 'thephpleague/flysystem'; |
| 78 | + |
| 79 | +$settings = new Settings($project); |
| 80 | + |
| 81 | +$cache = new Cache('/tmp/github-api-cache') |
| 82 | +$cacheClient = new CachedClient(); |
| 83 | +$cacheClient->setCache($cache); |
| 84 | + |
| 85 | +$client = new Client($cacheClient, $settings); |
| 86 | +$adapter = new GithubAdapter($client); |
| 87 | +$filesystem = new Filesystem($adapter); |
| 88 | + |
| 89 | +``` |
| 90 | + |
| 91 | +## Testing |
| 92 | + |
| 93 | +``` bash |
| 94 | +$ composer test |
| 95 | +``` |
| 96 | + |
| 97 | +## Contributing |
| 98 | + |
| 99 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 100 | + |
| 101 | +## Security |
| 102 | + |
| 103 | +If you discover any security related issues, please email [email protected] instead of using the issue tracker. |
| 104 | + |
| 105 | +## Credits |
| 106 | + |
| 107 | +- [Potherca](https://github.com/potherca) |
| 108 | + |
| 109 | +## License |
| 110 | + |
| 111 | +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
0 commit comments