pselge-daparto / php-gitlab-api
PHP 的 GitLab API v4 客户端
Requires
- php: ^7.1
- ext-json: *
- ext-xml: *
- php-http/cache-plugin: ^1.7
- php-http/client-common: ^2.3
- php-http/discovery: ^1.12
- php-http/httplug: ^2.1
- php-http/multipart-stream-builder: ^1.1
- psr/cache: ^1.0
- psr/http-client-implementation: ^1.0
- psr/http-factory-implementation: ^1.0
- psr/http-message: ^1.0
- symfony/deprecation-contracts: ^2.1
- symfony/options-resolver: ^3.4 || ^4.0 || ^5.0
- symfony/polyfill-php80: ^1.17
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4.1
- guzzlehttp/psr7: ^1.5.2
- http-interop/http-factory-guzzle: ^1.0
- php-http/guzzle6-adapter: ^2.0.1
Replaces
- m4tthumphrey/php-gitlab-api: 10.1.*
- 11.0.x-dev
- 10.2.x-dev
- 10.1.x-dev
- 10.1.3
- 10.1.2
- 10.1.1
- 10.1.0
- 10.0.x-dev
- 10.0.2
- 10.0.1
- 10.0.0
- 10.0.0-RC2
- 10.0.0-RC1
- 9.19.x-dev
- 9.19.2
- 9.19.1
- 9.19.0
- 9.18.x-dev
- 9.18.2
- 9.18.1
- 9.18.0
- 9.17.x-dev
- 9.17.1
- 9.17.0
- 9.16.0
- 9.15.0
- 9.14.0
- 9.13.0
- 9.12.0
- 9.11.0
- 9.10.0
- 9.9.0
- 9.8.0
- 9.7.0
- 9.6.1
- 9.6.0
- 9.5.0
- 9.4.0
- 9.3.0
- 9.2.0
- 9.1.0
- 9.0.0
- 9.0.0-rc1
- 9.0.0-beta2
- 9.0.0-beta1
- 8.0.x-dev
- 8.0.0
- 7.15.x-dev
- 7.15.0
- 7.14.0
- 7.13.1
- 7.13.0
- 7.11.0
- 7.10.0
- 7.9.0
- 7.8.0
- 6.9.1
- 6.9.0
- 6.4.3
- 6.2.2
- 6.2.1
- 6.2.0
- 6.1.0
- 6.0.0
- 0.7.1
- 0.7.0
- 0.6.1
- 0.6.0
This package is not auto-updated.
Last update: 2024-09-29 05:22:30 UTC
README
我们提供了一个现代的 GitLab API v4 PHP 客户端。
它基于 php-github-api,由 KnpLabs 开发。因此,我们现在有针对以下服务的非常相似的客户端:
- Bitbucket - bitbucket/client by Graham Campbell。
- GitHub - knplabs/github-api by KnpLabs。
- GitLab - pselge-daparto/php-gitlab-api,也就是这个包!
安装
此版本支持 PHP 7.1-7.4。要开始,只需使用 Composer 需求项目。您还需要安装提供 psr/http-client-implementation
和 psr/http-factory-implementation
的包。
标准安装
PHP 7.1+
$ composer require pselge-daparto/php-gitlab-api:^10.1 php-http/guzzle6-adapter:^2.0.1 http-interop/http-factory-guzzle:^1.0
PHP 7.2+
$ composer require pselge-daparto/php-gitlab-api:^10.1 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
框架集成
Laravel 6+
$ composer require graham-campbell/gitlab:^4.2 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
Symfony 4
$ composer require zeichen32/gitlabapibundle:^5.0 symfony/http-client:^4.4 nyholm/psr7:^1.3
Symfony 5
$ composer require zeichen32/gitlabapibundle:^5.0 symfony/http-client:^5.0 nyholm/psr7:^1.3
我们使用 PSR-7、PSR-17、PSR-18 和 HTTPlug 与任何 HTTP 消息客户端解耦。您可以访问 HTTPlug 获取有关安装 HTTPlug 相关包的更多信息。框架集成 graham-campbell/gitlab 由 Graham Campbell 提供,而 zeichen32/gitlabapibundle 由 Jens Averkamp 提供。
通用 API 使用
// Token authentication $client = new Gitlab\Client(); $client->authenticate('your_http_token', Gitlab\Client::AUTH_HTTP_TOKEN); // OAuth2 authentication $client = new Gitlab\Client(); $client->authenticate('your_oauth_token', Gitlab\Client::AUTH_OAUTH_TOKEN); // An example API call $project = $client->projects()->create('My Project', [ 'description' => 'This is a project', 'issues_enabled' => false, ]);
自托管 GitLab
$client = new Gitlab\Client(); $client->setUrl('https://git.yourdomain.com'); $client->authenticate('your_http_token', Gitlab\Client::AUTH_HTTP_TOKEN);
带有分页器的示例
$pager = new Gitlab\ResultPager($client); $issues = $pager->fetchAll($client->issues(), 'all', [null, ['state' => 'closed']]);
HTTP 客户端构建器
通过向 Gitlab\Client
构造函数提供一个 Gitlab\HttpClient\Builder
,您可以自定义 HTTP 客户端。例如,要自定义用户代理
$plugin = new Http\Client\Common\Plugin\HeaderSetPlugin([ 'User-Agent' => 'Foobar', ]); $builder = new Gitlab\HttpClient\Builder(); $builder->addPlugin($plugin); $client = new Gitlab\Client($builder);
您可以在这里了解更多关于 HTTPlug 插件的信息。请查看API 方法,并且请随时报告任何错误,注意我们的行为准则。
贡献
我们乐意接收问题报告并审查接受拉取请求,遵循我们的行为准则和贡献指南!
$ make install
$ make test
安全性
如果您在这个包中发现安全漏洞,请将邮件发送到 Graham Campbell 的 graham@alt-three.com 或 Miguel Piedrafita 的 github@miguelpiedrafita.com。所有安全漏洞都将得到及时处理。您可以在此查看我们的完整安全策略。
许可证
GitLab PHP API 客户端遵循MIT 许可证 (MIT)。