maxikg / github-api-bundle
knplabs/github-api 在 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: 2024-09-26 00:47:15 UTC
README
在 KnpLabs/php-github-api 和 Symfony 2/3 之间建立一个简单的桥梁。
安装
使用 composer 安装包
composer require maxikg/github-api-bundle
现在注册包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Maxikg\GithubApiBundle\GithubApiBundle(), ); // ... }
配置
默认配置如下
# 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
cache配置缓存客户端。enabled(布尔值) 允许开启或关闭缓存。service(字符串) 允许指定自定义缓存服务。缓存必须实现Github\HttpClient\Cache\CacheInterface
client配置客户端选项。允许的设置可能因实现而异。但是,默认值是base_url(字符串) 指定基本 API URL(如果您使用 GitHub Enterprise,应使用下面描述的enterprise_url配置)。user_agent(字符串) 指定User-Agent头的值。 GitHub 喜欢在这里看到您的或您的应用程序的名称。timeout(整数) 指定连接超时时间(以秒为单位)。api_limit(整数) 未知用途。api_version(字符串) 请求的 API 版本。cache_dir(字符串) 缓存目录。但我建议使用cache配置部分以避免问题。
enterprise_url(字符串) 配置 GitHub Enterprise 实例的 URL。authentication配置与 API 的身份验证。您可以在大多数情况下不进行身份验证而使用 GitHub.com API,但 GH Enterprise 几乎需要对所有内容进行身份验证。type(字符串) 身份验证类型none为禁用身份验证。url_token通过设置access_token参数将 OAuth Token 添加到 URL。url_client_id通过设置client_id和client_secret参数将您的客户端 ID 和密钥添加到 URL。http_password通过设置您的用户名和密码通过 HTTP 头进行身份验证。如果启用了两步验证,则不会工作。http_token通过将 OAuth Token 添加到 HTTP 头进行身份验证。
token(字符串) 指定 OAuth Token。仅适用于url_token和http_token类型。client_id(字符串) 指定客户端 ID。仅适用于url_client_id类型。client_secret(字符串) 指定客户端密钥。仅适用于url_client_id类型。username(字符串) 指定您的用户名。仅适用于http_password类型。password(字符串) 指定您的密码。仅适用于http_password类型。
但您不必配置此包。它也将使用默认值。
使用
您可以通过要求服务 github.client 来获取 Github\Client 的实例。
有关更详细的说明,请参阅此处: https://github.com/KnpLabs/php-github-api/tree/1.6.0/doc
可能即将推出的功能
- 额外的缓存适配器
- 使用实体进行 Doctrine
- 使用 doctrine/DoctrineCacheBundle) 的 Doctrine 缓存适配器
- 多客户端配置
- 在
Resources/docs文件夹中的更好的文档 - 与 Symfony <2.8 的兼容性检查
许可证
请参阅 LICENSE.txt。不必担心,它是 MIT 许可证。