maxikg / github-api-bundle
A bridge for using knplabs/github-api in Symfony 2/3.
dev-master
2016-06-22 11:35 UTC
Requires
- php: >=5.3.3
- knplabs/github-api: ~1.4
- symfony/config: ~2.7|~3.0
- symfony/dependency-injection: ~2.7|~3.0
- symfony/http-kernel: ~2.7|~3.0
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is not auto-updated.
Last update: 2025-08-14 05:22:07 UTC
README
A simple bridge between KnpLabs/php-github-api and Symfony 2/3.
Installation
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(), ); // ... }
Configuration
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: null
cacheconfigures 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.
Usage
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
Possibly upcoming features
- 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
License
See LICENSE.txt. Don't worry, it's the MIT license.