caherrera / php-gitlab-api
PHP的GitLab API v4客户端
资助包维护!
GrahamCampbell
Requires
- php: ^7.2.5 || ^8.0
- ext-json: *
- ext-xml: *
- php-http/cache-plugin: ^1.7.1
- php-http/client-common: ^2.3
- php-http/discovery: ^1.12
- php-http/httplug: ^2.2
- php-http/multipart-stream-builder: ^1.1.2
- psr/cache: ^1.0
- psr/http-client-implementation: ^1.0
- psr/http-factory-implementation: ^1.0
- psr/http-message: ^1.0
- symfony/options-resolver: ^3.4 || ^4.0 || ^5.0
- symfony/polyfill-php80: ^1.17
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4.1
- guzzlehttp/guzzle: ^7.2
- http-interop/http-factory-guzzle: ^1.0
- 11.5.x-dev
- 11.4.x-dev
- 11.4.0
- 11.3.x-dev
- 11.3.0
- 11.2.x-dev
- 11.2.1
- 11.2.0
- 11.1.x-dev
- 11.1.0
- 11.0.x-dev
- 11.0.0
- 10.5.x-dev
- 10.5.0
- 10.4.x-dev
- 10.4.1.x-dev
- 10.4.0
- 10.3.x-dev
- 10.3.1
- 10.3.0
- 10.2.x-dev
- 10.2.0
- 10.1.x-dev
- 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
- dev-10.4-dev
This package is auto-updated.
Last update: 2024-09-15 07:35:48 UTC
README
我们提供了一个用于PHP的现代化GitLab API v4客户端。
该项目基于php-github-api,由KnpLabs开发。考虑到这一点,我们现在有了以下类似的客户端:
- Bitbucket - bitbucket/client by Graham Campbell。
- GitHub - knplabs/github-api by KnpLabs。
- GitLab - m4tthumphrey/php-gitlab-api,即本包!
请查看变更日志、发布、安全策略、许可证、行为准则和贡献指南。
安装
此版本支持PHP 7.2-8.0。要开始使用,请使用Composer要求项目。您还需要安装提供“psr/http-client-implementation
”和“psr/http-factory-implementation
”的包。
标准安装
$ composer require "m4tthumphrey/php-gitlab-api:^11.4" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"
框架集成
Laravel
$ composer require "graham-campbell/gitlab:^5.2" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"
Symfony
$ composer require "zeichen32/gitlabapibundle:^6.0" "symfony/http-client:^5.2" "nyholm/psr7:^1.3"
我们通过使用PSR-7、PSR-17、PSR-18和HTTPlug与任何HTTP消息客户端解耦。您可以通过访问HTTPlug for library users获取有关安装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。所有安全漏洞都将得到及时解决。您可以在这里查看我们的完整安全策略这里。
许可
GitLab PHP API 客户端遵循MIT 许可证 (MIT)进行授权。