Client

GitLabPHPMIT更新放缓

PHP 版 GitLab API v4 客户端,封装了仓库、合并请求、流水线等接口调用,省去手写 HTTP 请求和鉴权逻辑。

GitLab API v4 client for PHP

12.1.0发布于 2026-05-06 21:18 UTC951star450fork同步于 2026-11-07 07:32 UTC

怎么上手

README 里没有找到可直接复制的安装命令

README 里没有找到可直接复制的安装命令,请到 README 或官方文档查看安装方式。

硬件要求

README 没有说明硬件要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

这个项目的说明还在生成中,先参考下面「最近发版」和 README。

最近发版

5 个版本12.1.0
  1. 12.1.012.1.0 (06/05/2026)最新正式版2026-05-06 · 2026-05-06 21:18 UTC
    • Add PHP 8.5 support
    • Add support for symfony/options-resolver:^8.0
    • Add sensitive parameter annotations for authentication, trigger tokens, and user passwords
    • Add support for force in Repositories::createCommit
    • Add support for personal access tokens
    • Add support for project access token filters and rotation
    • Add support for project CI/CD job token scope endpoints
    • Add support for project integrations, push rules, and remote mirror read endpoints
    • Add support for permanent project removal and project restoration
    • Add support for Projects::updateDeployKey
    • Add support for Projects::latestPipeline
    • Add support for additional parameters in Projects::fork
    • Add support for inputs in Projects::createPipeline
    • Add support for job_inputs and job_variables_attributes in Jobs::play
    • Add support for visibility in Groups::all
    • Add support for with_custom_attributes and with_projects in Groups::show
    • Add support for last_activity_after and last_activity_before in Groups::projects
    • Add support for group hook endpoints
    • Add support for date filters and finished_at ordering in Deployments::all
    • Add support for Environments::stopStale
    • Add support for container registry endpoints
    • Add support for regex and sort in Repositories::branches
    • Add support for Users::usersContributedProjects
    • Add support for without_project_bots in Users::all
    • Add support for additional filters and ordering options in MergeRequests::all
    • Add support for listing merge requests associated with commits and deployments
    • Add support for merge request dependency, merge train, removal, resource label event, and award emoji endpoints
    • Correct merge request API parameter handling
    • Correct project forks list parameter handling
    • Fix recent list endpoints to rely on the result pager for pagination
    • Fix Projects::pipelines date filters to include time information
  2. 12.0.012.0.0 (23/02/2025)2025-02-23 · 2025-02-23 20:39 UTC
    查看更新说明
    • Add PHP 8.4 support
    • Drop support for PHP earlier than 8.1
    • Moved various param types to native PHP types
  3. 11.14.011.14.0 (17/03/2024)2024-03-17 · 2024-03-17 21:38 UTC
    查看更新说明
    • Add support for php-http/cache-plugin:^2.0
    • Add support for 'approved' status in Project::events
    • Add support for name in createRelease and updateRelease
    • Add support for date filtering to GroupsMilestones::all()
    • Update MergeRequests::all to use millisecond precision for date filters
  4. 11.13.011.13.0 (03/12/2023)2023-12-03 · 2023-12-03 22:42 UTC
    查看更新说明
    • Add support for symfony/options-resolver:^7.0
    • Add support for status and environment in Deployments::all
    • Add support for Groups::search, Projects::search, and Search::all
  5. 11.12.011.12.0 (08/10/2023)2023-10-08 · 2023-10-08 14:28 UTC
    查看更新说明
    • Add PHP 8.3 support
    • Add Projects::updateProtectedBranch and Projects::updateApprovalsConfiguration
    • Add support for environment_scope in Projects::removeVariable
    • Add support for filter in Projects::variable
    • Add support for author in Repositories::commits
    • Add support for additional parameters in Projects::labels and Groups::labels

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    GitLab PHP API Client

    We present a modern GitLab API v4 client for PHP.

    Banner

    This is strongly based on php-github-api by KnpLabs. With this in mind, we now have very similar clients for:

    Check out the change log, releases, security policy, license, code of conduct, and contribution guidelines.

    Installation

    This version supports PHP 8.1-8.5. To get started, simply require the project using Composer. You will also need to install packages that "provide" psr/http-client-implementation and psr/http-factory-implementation.

    Standard Installation

    $ composer require "m4tthumphrey/php-gitlab-api:^12.1" "guzzlehttp/guzzle:^7.9.2"
    

    Framework Integration

    Laravel:
    $ composer require "graham-campbell/gitlab:^8.1"
    
    Symfony:
    $ composer require "zeichen32/gitlabapibundle:^7.0"
    

    We are decoupled from any HTTP messaging client by using PSR-7, PSR-17, PSR-18, and HTTPlug. You can visit HTTPlug for library users to get more information about installing HTTPlug related packages. The framework integration graham-campbell/gitlab is by Graham Campbell and zeichen32/gitlabapibundle is by Jens Averkamp.

    General API Usage

    $client = new Gitlab\Client();
    
    // Choose one authentication method.
    
    // Personal access token authentication
    $client->authenticate('your_access_token', Gitlab\Client::AUTH_HTTP_TOKEN);
    
    // OAuth2 authentication
    // $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_access_level' => 'disabled',
    ]);
    

    Self-Hosted GitLab

    $client = new Gitlab\Client();
    $client->setUrl('https://git.yourdomain.com');
    $client->authenticate('your_access_token', Gitlab\Client::AUTH_HTTP_TOKEN);
    

    Example with Pager

    $pager = new Gitlab\ResultPager($client);
    $issues = $pager->fetchAll($client->issues(), 'all', [null, ['state' => 'closed']]);
    

    HTTP Client Builder

    By providing a Gitlab\HttpClient\Builder to the Gitlab\Client constructor, you can customize the HTTP client. For example, to customize the user agent:

    $plugin = new Http\Client\Common\Plugin\HeaderSetPlugin([
        'User-Agent' => 'Foobar',
    ]);
    
    $builder = new Gitlab\HttpClient\Builder();
    $builder->addPlugin($plugin);
    
    $client = new Gitlab\Client($builder);
    

    One can read more about HTTPlug plugins here. Take a look around the API methods, and please feel free to report any bugs, noting our code of conduct.

    Contributing

    We will gladly receive issue reports and review and accept pull requests, in accordance with our code of conduct and contribution guidelines!

    $ make install
    $ make test
    

    Security

    If you discover a security vulnerability within this package, please send an email to Graham Campbell at [email protected]. All security vulnerabilities will be promptly addressed. You may view our full security policy here.

    License

    GitLab PHP API Client is licensed under The MIT License (MIT).