A simple bridge between KnpLabs/php-github-api and Symfony 2/3.
Require the bundle with composer:
composer require maxikg/github-api-bundle
Now register the bundle:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Maxikg\GithubApiBundle\GithubApiBundle(),
);
// ...
}The default configuration looks like:
# app/config/config.yml
github_api:
cache:
enabled: false
service: github.http.cache
client: null
enterprise_url: null
authentication:
type: none
token: null
client_id: null
client_secret: null
username: null
password: nullcacheconfigures the cached client.enabled(boolean) allows to turn the cache on or off.service(string) allows to specify a custom cache service. A cache must implementsGithub\HttpClient\Cache\CacheInterface
clientconfigures client options. The allowed settings may vary from implementation to implementation. However, the defaults are:base_url(string) specify the base API url (if you're using GitHub Enterprise you should use theenterprise_urlconfiguration described below).user_agent(string) specify the value for theUser-Agentheader. GitHub likes to see your or your applications name here.timeout(integer) specifies the connection time out in seconds.api_limit(integer) unknown purpose.api_version(string) the requested api version.cache_dir(string) the cache directory. But I recommend to use thecacheconfiguration section instead to avoid problems.
enterprise_url(string) configures a url for a GitHub Enterprise instance.authenticationconfigures the authentication with the api. You can use the GitHub.com API mostly without major restrictions without an authentication. GH Enterprise requires the authentication for nearly anything.type(string) the authentication type:nonefor disabled authentication.url_tokenfor appending an OAuth Token to the url by setting theaccess_tokenparameter.url_client_idfor appending your client's id and secret to the url by setting theclient_idandclient_secretparameter.http_passwordfor authenticating via HTTP header by setting your username and password. This won't work, if two factor authentication is enabled.http_tokenfor appending an OAuth Token to the HTTP headers.
token(string) specifies the OAuth Token. Only forurl_tokenandhttp_tokentypes.client_id(string) specifies the client id. Only forurl_client_idtype.client_secret(string) specifies the client secret. Only forurl_client_idtype.username(string) specifies your username. Only forhttp_passwordtype.password(string) specifies your password. Only forhttp_passwordtype.
But you aren't required to configure this Bundle. It will also work with the defaults.
You can obtain a instance of Github\Client by require the service
github.client.
For a more detailed instruction, please refer here: https://github.com/KnpLabs/php-github-api/tree/1.6.0/doc
- Additional cache adapters:
- Doctrine using entities
- Doctrine Cache adapter using doctrine/DoctrineCacheBundle)
- Multi client configuration
- A better documentation in the
Resources/docsfolder - Compatibility checks against Symfony <2.8
See LICENSE.txt. Don't worry, it's the MIT license.