codenamephp / platform.github

此软件包已被弃用且不再维护。未建议替代软件包。

0.1 2016-04-04 21:09 UTC

This package is auto-updated.

Last update: 2020-08-18 20:03:59 UTC


README

基于https://github.com/KnpLabs/php-github-api的访问github API的组件

#安装只需将包添加到composer

...
  "require": {
    "php": ">=7",
    "codenamephp/platform.github": "*"
  },
...

然后,将\de\codenamephp\platform\github\DefinitionProvider添加到DI容器中

$containerBuilder = new \de\codenamephp\platform\di\ContainerBuilder();
$containerBuilder->addDefinitionsByProvider(new \de\codenamephp\platform\github\DefinitionProvider());
return $containerBuilder;

#使用##认证GitHub在执行任何API调用之前都需要认证。有多种认证方法可供选择。完整的列表和文档可以在GitHub帮助文档中找到:https://developer.github.com/v3/oauth_authorizations/https://developer.github.com/v3/auth/###API Token (https://github.com/blog/1509-personal-api-tokens) 要通过API Token进行认证,只需从DI容器请求de\codenamephp\platform\github\ApiToken并调用authenticate()即可

$diContainer->get(de\codenamephp\platform\github\ApiToken::class)->authenticate();

需要在DI容器中设置github.apiToken条目,否则无法创建实例。