Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 1.77 KB

contents.md

File metadata and controls

56 lines (39 loc) · 1.77 KB

Repo / Contents API

Back to the "Repos API" | Back to the navigation

Get a repository's README

$readme = $client->api('repo')->contents()->readme('knp-labs', 'php-github-api', $reference);

Get information about a repository file or directory

$fileInfo = $client->api('repo')->contents()->show('knp-labs', 'php-github-api', $path, $reference);

Check that a file or directory exists in the repository

$fileExists = $client->api('repo')->contents()->exists('knp-labs', 'php-github-api', $path, $reference);

Create a file

$committer = array('name' => 'KnpLabs', 'email' => '[email protected]');

$fileInfo = $client->api('repo')->contents()->create('knp-labs', 'php-github-api', $path, $content, $commitMessage, $branch, $committer);

Update a file

$committer = array('name' => 'KnpLabs', 'email' => '[email protected]');
$oldFile = $client->api('repo')->contents()->show('knp-labs', 'php-github-api', $path, $branch);

$fileInfo = $client->api('repo')->contents()->update('knp-labs', 'php-github-api', $path, $content, $commitMessage, $oldFile['sha'], $branch, $committer);

Remove a file

$committer = array('name' => 'KnpLabs', 'email' => '[email protected]');
$oldFile = $client->api('repo')->contents()->show('knp-labs', 'php-github-api', $path, $branch);

$fileInfo = $client->api('repo')->contents()->rm('knp-labs', 'php-github-api', $path, $commitMessage, $oldFile['sha'], $branch, $committer);

Get repository archive

$archive = $client->api('repo')->contents()->archive('knp-labs', 'php-github-api', $format, $reference);

Download a file

$fileContent = $client->api('repo')->contents()->download('knp-labs', 'php-github-api', $path, $reference);