benmag/php-gitlab-api
Composer 安装命令:
composer require benmag/php-gitlab-api
包简介
GitLab API client
README 文档
README
Based on php-github-api and code from KnpLabs.
Installation
Via composer
composer require m4tthumphrey/php-gitlab-api php-http/guzzle6-adapter:^1.0
Why php-http/guzzle6-adapter? We are decoupled from any HTTP messaging client with help by HTTPlug.
You can visit HTTPlug for library users to get more information about installing HTTPlug related packages.
Versioning
Depending on your Gitlab server version, you must choose the right version of this library. Please refer to the following table to pick the right one.
| Version | Gitlab API Version | Gitlab Version |
|---|---|---|
| 9.x | V4 | >= 9.0 |
| 8.x | V3 | < 9.5 |
General API Usage
$client = \Gitlab\Client::create('http://git.yourdomain.com') ->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN) ; // or for OAuth2 (see https://github.com/m4tthumphrey/php-gitlab-api/blob/master/lib/Gitlab/HttpClient/Plugin/Authentication.php#L47) $client = \Gitlab\Client::create('http://gitlab.yourdomain.com') ->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_OAUTH_TOKEN) ; $project = $client->api('projects')->create('My Project', array( 'description' => 'This is a project', 'issues_enabled' => false ));
Example with Pager
to fetch all your closed issue with pagination ( on the gitlab api )
$client = \Gitlab\Client::create('http://git.yourdomain.com') ->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN) ; $pager = new \Gitlab\ResultPager($client); $issues = $pager->fetchAll($client->api('issues'),'all',[null, ['state' => 'closed']]);
Model Usage
You can also use the library in an object oriented manner:
$client = \Gitlab\Client::create('http://git.yourdomain.com') ->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN) ; # Creating a new project $project = \Gitlab\Model\Project::create($client, 'My Project', array( 'description' => 'This is my project', 'issues_enabled' => false )); $project->addHook('http://mydomain.com/hook/push/1'); # Creating a new issue $project = new \Gitlab\Model\Project(1, $client); $issue = $project->createIssue('This does not work.', array( 'description' => 'This doesn\'t work properly. Please fix.', 'assignee_id' => 2 )); # Closing that issue $issue->close();
You get the idea! Take a look around (API methods, models) and please feel free to report any bugs.
Framework Integrations
- Symfony - https://github.com/Zeichen32/GitLabApiBundle
- Laravel - https://github.com/GrahamCampbell/Laravel-GitLab
If you have integrated GitLab into a popular PHP framework, let us know!
Contributing
There are many parts of Gitlab that I have not added to this as it was originally created for personal use, hence the lack of tests. Feel free to fork and add new functionality and tests, I'll gladly accept decent pull requests.
benmag/php-gitlab-api 适用场景与选型建议
benmag/php-gitlab-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「gitlab」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 benmag/php-gitlab-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 benmag/php-gitlab-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 benmag/php-gitlab-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP GitLab generic API client (not stick to any version)
A collection of monolog handlers using PSR-18 http client
A PSR-7 compatible library for making CRUD API endpoints
Creates & updates issues on a GitLab repository from Symfony2 exceptions
Library to handle Webhooks from various services.
A PSR-15 middleware to manage Gitlab hooks.
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-25