|
| 1 | +## Repo / Contents API |
| 2 | +[Back to the "Repos API"](../repos.md) | [Back to the navigation](../index.md) |
| 3 | + |
| 4 | +### Get a repository's README |
| 5 | + |
| 6 | +```php |
| 7 | +$readme = $client->api('repo')->contents()->readme('knp-labs', 'php-github-api', $reference); |
| 8 | +``` |
| 9 | + |
| 10 | +### Get information about a repository file or directory |
| 11 | + |
| 12 | +```php |
| 13 | +$fileInfo = $client->api('repo')->contents()->show('knp-labs', 'php-github-api', $path, $reference); |
| 14 | +``` |
| 15 | + |
| 16 | +### Check that a file or directory exists in the repository |
| 17 | +```php |
| 18 | +$fileExists = $client->api('repo')->contents()->exists('knp-labs', 'php-github-api', $path, $reference); |
| 19 | +``` |
| 20 | + |
| 21 | +### Create a file |
| 22 | +```php |
| 23 | +$committer = array('name' => 'KnpLabs', 'email' => ' [email protected]'); |
| 24 | + |
| 25 | +$fileInfo = $client->api('repo')->contents()->create('knp-labs', 'php-github-api', $path, $content, $commitMessage, $branch, $committer); |
| 26 | +``` |
| 27 | + |
| 28 | +### Update a file |
| 29 | + |
| 30 | +```php |
| 31 | +$committer = array('name' => 'KnpLabs', 'email' => ' [email protected]'); |
| 32 | +$oldFile = $client->api('repo')->contents()->show('knp-labs', 'php-github-api', $path, $branch); |
| 33 | + |
| 34 | +$fileInfo = $client->api('repo')->contents()->create('knp-labs', 'php-github-api', $path, $content, $commitMessage, $oldFile['sha'], $branch, $committer); |
| 35 | +``` |
| 36 | + |
| 37 | +### Remove a file |
| 38 | + |
| 39 | +```php |
| 40 | +$committer = array('name' => 'KnpLabs', 'email' => ' [email protected]'); |
| 41 | +$oldFile = $client->api('repo')->contents()->show('knp-labs', 'php-github-api', $path, $branch); |
| 42 | + |
| 43 | +$fileInfo = $client->api('repo')->contents()->rm('knp-labs', 'php-github-api', $path, $commitMessage, $oldFile['sha'], $branch, $committer); |
| 44 | +``` |
| 45 | + |
| 46 | +### Get repository archive |
| 47 | + |
| 48 | +```php |
| 49 | +// @todo Document |
| 50 | +``` |
| 51 | + |
| 52 | +### Download a file |
| 53 | + |
| 54 | +```php |
| 55 | +$fileContent = $client->api('repo')->contents()->download('knp-labs', 'php-github-api', $path, $reference); |
| 56 | +``` |
0 commit comments