Skip to content

update from upstream #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* text=auto

/doc export-ignore
/test export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/README.markdown export-ignore
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm

before_script:
- composer install --dev --prefer-source
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source --dev

script:
- phpunit --coverage-text
- vendor/bin/phpunit --verbose --coverage-text
34 changes: 23 additions & 11 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Uses [GitHub API v3](http://developer.github.com/v3/). The object API is very si
## Requirements

* PHP >= 5.3.2 with [cURL](http://php.net/manual/en/book.curl.php) extension,
* [Buzz](https://github.com/kriswallsmith/Buzz) library,
* [Guzzle](https://github.com/guzzle/guzzle) library,
* (optional) PHPUnit to run tests.

## Autoload
Expand All @@ -33,17 +33,28 @@ $ php composer.phar install
```
Now we can use autoloader from Composer by:

```yaml
```json
{
"require": {
"knplabs/github-api": "*"
},
"minimum-stability": "dev"
"knplabs/github-api": "~1.2"
}
}
```

> `php-github-api` follows the PSR-0 convention names for its classes, which means you can easily integrate `php-github-api` classes loading in your own autoloader.

## Using Laravel?

[Laravel GitHub](https://github.com/GrahamCampbell/Laravel-GitHub) by [Graham Campbell](https://github.com/GrahamCampbell) might interest you.

```json
{
"require": {
"graham-campbell/github": "0.1.*"
}
}
```

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

```php
Expand All @@ -52,7 +63,7 @@ Now we can use autoloader from Composer by:
// This file is generated by Composer
require_once 'vendor/autoload.php';

$client = new Github\Client();
$client = new \Github\Client();
$repositories = $client->api('user')->repositories('ornicar');
```

Expand All @@ -66,19 +77,19 @@ From `$client` object, you can access to all GitHub.
// This file is generated by Composer
require_once 'vendor/autoload.php';

$client = new Github\Client(
new Github\HttpClient\CachedHttpClient(array('cache_dir' => '/tmp/github-api-cache'))
$client = new \Github\Client(
new \Github\HttpClient\CachedHttpClient(array('cache_dir' => '/tmp/github-api-cache'))
);

// Or select directly which cache you want to use
$client = new Github\HttpClient\CachedHttpClient();
$client = new \Github\HttpClient\CachedHttpClient();
$client->setCache(
// Built in one, or any cache implementing this interface:
// Github\HttpClient\Cache\CacheInterface
new Github\HttpClient\Cache\FilesystemCache('/tmp/github-api-cache')
new \Github\HttpClient\Cache\FilesystemCache('/tmp/github-api-cache')
);

$client = new Github\Client($client);
$client = new \Github\Client($client);
```

Using cache, the client will get cached responses if resources haven't changed since last time,
Expand All @@ -102,6 +113,7 @@ See the `doc` directory for more detailed documentation.
### Contributors

- Thanks to [Thibault Duplessis aka. ornicar](http://github.com/ornicar) for his first version of this library.
- Thanks to [Joseph Bielawski aka. stloyd](http://github.com/stloyd) for his contributions and support.
- Thanks to [noloh](http://github.com/noloh) for his contribution on the Object API.
- Thanks to [bshaffer](http://github.com/bshaffer) for his contribution on the Repo API.
- Thanks to [Rolf van de Krol](http://github.com/rolfvandekrol) for his countless contributions.
Expand Down
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@
}
],
"require": {
"php": ">=5.3.2",
"ext-curl": "*",
"kriswallsmith/buzz": ">=0.7"
"php": ">=5.3.2",
"ext-curl": "*",
"guzzle/guzzle": "~3.7"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"suggest": {
"knplabs/gaufrette": "Needed for optional Gaufrette cache"
},
"autoload": {
"psr-0": { "Github\\": "lib/" }
},
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
"dev-master": "1.3.x-dev"
}
}
}
52 changes: 52 additions & 0 deletions doc/authorizations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
## Authorizations API
[Back to the navigation](index.md)

Creating, deleting and listing authorizations. Wraps [GitHub Authorizations API](http://developer.github.com/v3/oauth/).

#### List all authorizations.

```php
$authorizations = $github->api('authorizations')->all();
```

#### Get a single authorization

```php
$authorization = $github->api('authorizations')->show(1);
```

#### Create an authorization

```php
$data = array(
'note' => 'This is an optional description'
);

$authorization = $github->api('authorizations')->create($data);
```

Creates and returns an authorization.

#### Update an authorization

You can update ``note``.

```php
$data = array(
'note' => 'This is new note'
);

$authorization = $github->api('authorizations')->update(1234, $data);
```

#### Delete an authorization

```php
$authorization = $github->api('authorizations')->remove(1234);
```

#### Check an authorization

```php
$authorization = $github->api('authorizations')->check(1234, 'token');
```
24 changes: 24 additions & 0 deletions doc/enterprise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Enterprise API
[Back to the navigation](index.md)

Provides information about a GitHub Enterprise installation. Wraps [GitHub Enterprise API](http://developer.github.com/v3/enterprise/).

In order to configure the client to point to a GitHub Enterprise installation, do the following:

```php
<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';

$client = new \Github\Client();

// Set the URL of your GitHub Enterprise installation
$client->setEnterpriseUrl('https://ghe.host');

// Use the client as you would ordinarily
$repositories = $client->api('user')->repositories('ornicar');
```

To use the Stats and License APIs, you will need to authenticate using a GitHub Enterprise site admin account.

2 changes: 1 addition & 1 deletion doc/gists.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ $data = array(
'description' => 'This is new description'
);

$gist = $github->api('gists')->update($data);
$gist = $github->api('gists')->update(1234, $data);
```

You can update ``content`` of a previous file's version.
Expand Down
7 changes: 7 additions & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Navigation
==========

APIs:
* [Authorizations](authorizations.md)
* [Commits](commits.md)
* [Enterprise](enterprise.md)
* [Gists](gists.md)
* [Issues](issues.md)
* [Comments](issue/comments.md)
Expand All @@ -13,10 +15,15 @@ APIs:
* [Pull Requests](pull_requests.md)
* [Comments](pull_request/comments.md)
* [Repositories](repos.md)
* [Contents](repo/contents.md)
* [Releases](repo/releases.md)
* [Assets](repo/assets.md)
* [Users](users.md)
* [Meta](meta.md)

Additional features:

* [Pagination support](result_pager.md)
* [Authentication & Security](security.md)
* [Request any Route](request_any_route.md)
* [Customize `php-github-api` and testing](customize.md)
55 changes: 51 additions & 4 deletions doc/issue/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,24 @@ Wraps [GitHub Issue Comments API](http://developer.github.com/v3/issues/comments
$comments = $client->api('issue')->comments()->all('KnpLabs', 'php-github-api', 4);
```

List an issue comments by username, repo and issue number.
Returns an array of issues.
* `KnpLabs` : the owner of the repository
* `php-github-api` : the name of the repository
* `4` : the id of the issue
* You can select another page of comments using one more parameter (default: 1)

Returns an array of comments.


### Show an issue comment

```php
$comment = $client->api('issue')->comments()->show('KnpLabs', 'php-github-api', 33793831);
```

* `KnpLabs` : the owner of the repository
* `php-github-api` : the name of the repository
* `33793831` : the id of the comment


### Add a comment on an issue

Expand All @@ -23,5 +39,36 @@ Returns an array of issues.
$client->api('issue')->comments()->create('KnpLabs', 'php-github-api', 4, array('body' => 'My new comment'));
```

Add a comment to the issue by username, repo and issue number and array with comment data: `body`
and optionally `title`.
* `KnpLabs` : the owner of the repository
* `php-github-api` : the name of the repository
* `4` : the id of the issue
* You can set a `body` and optionally a `title`


### Update a comment on an issue

> **Note:**

> Requires [authentication](../security.md).

```php
$client->api('issue')->comments()->create('KnpLabs', 'php-github-api', 33793831, array('body' => 'My updated comment'));
```

* `KnpLabs` : the owner of the repository
* `php-github-api` : the name of the repository
* `33793831` : the id of the comment

### Remove a comment on an issue

> **Note:**

> Requires [authentication](../security.md).

```php
$client->api('issue')->comments()->remove('KnpLabs', 'php-github-api', 33793831);
```

* `KnpLabs` : the owner of the repository
* `php-github-api` : the name of the repository
* `33793831` : the id of the comment
29 changes: 29 additions & 0 deletions doc/meta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Users API
[Back to the navigation](index.md)


Wrap [GitHub User API](http://developer.github.com/v3/meta/).

### Get information about GitHub services

```php
$service = $client->api('meta')->service();
```

return

```
array(3) {
'verifiable_password_authentication' => bool
'hooks' =>
array(1) {
[0] =>
string(15) "127.0.0.1/22"
}
'git' =>
array(1) {
[0] =>
string(15) "127.0.0.1/22"
}
}
```
32 changes: 32 additions & 0 deletions doc/repo/assets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Repo / Releases API
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../index.md)

### List all assets by release

```php
$assets = $client->api('repo')->releases()->assets()->all('twbs', 'bootstrap', $releaseId);
```

### List one asset

```php
$asset = $client->api('repo')->releases()->assets()->show('twbs', 'bootstrap', $assetId);
```

### Create an asset

```php
$asset = $client->api('repo')->releases()->assets()->create('twbs', 'bootstrap', $releaseId, $name, $contentType, $content);
```

### Edit an asset

```php
$asset = $client->api('repo')->releases()->assets()->edit('twbs', 'bootstrap', $assetId, array('name' => 'New name'));
```

### Remove an asset

```php
$asset = $client->api('repo')->releases()->assets()->remove('twbs', 'bootstrap', $assetId);
```
Loading