GitLab API client

Fund package maintenance!

Installs: 1 013 682

Dependents: 50

Suggesters: 3

Security: 0

Stars: 694

Watchers: 29

Forks: 341

Open Issues: 40

9.17.1 2020-07-04 20:22 UTC


We present a PHP client for GitLab's API v4.

Build Status StyleCI Latest Stable Version Total Downloads License

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


This version supports PHP 5.6-7.4. To get started, simply require the project using Composer. You will also need to install any package that "provides" php-http/client-implementation.

PHP 5.6+:

$ composer require m4tthumphrey/php-gitlab-api:^9.18 php-http/guzzle6-adapter:^2.0.1

Laravel 5.5+:

$ composer require graham-campbell/gitlab:^2.7 php-http/guzzle6-adapter:^2.0.1

Symfony 3+:

$ composer require zeichen32/gitlabapibundle:^2.6 php-http/guzzle6-adapter:^2.0.1

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. graham-campbell/gitlab is by Graham Campbell and zeichen32/gitlabapibundle is by Jens Averkamp.

General API Usage

// Token authentication
$client = Gitlab\Client::create('http://git.yourdomain.com')
    ->authenticate('your_gitlab_token_here', Gitlab\Client::AUTH_HTTP_TOKEN)

// OAuth2 authentication
$client = Gitlab\Client::create('http://gitlab.yourdomain.com')
    ->authenticate('your_gitlab_token_here', Gitlab\Client::AUTH_OAUTH_TOKEN)

$project = $client->projects()->create('My Project', [
    '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_HTTP_TOKEN)

$pager = new Gitlab\ResultPager($client);
$issues = $pager->fetchAll($client->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_HTTP_TOKEN)

// Creating a new project
$project = Gitlab\Model\Project::create($client, 'My Project', [
    'description' => 'This is my project',
    'issues_enabled' => false,


// Creating a new issue
$project = new Gitlab\Model\Project(1, $client);
$issue = $project->createIssue('This does not work.', [
    'description' => 'This doesn\'t work properly. Please fix.',
    'assignee_id' => 2,

// Closing that issue

The 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();

$client = new Gitlab\Client($builder);

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


Not all endpoints of the API are implemented yet. We will gladly review and accept pull requests, in accordance with our contribution guidelines!

$ make install
$ make test


If you discover a security vulnerability within this package, please send an email to Graham Campbell at graham@alt-three.com or Miguel Piedrafita at github@miguelpiedrafita.com. All security vulnerabilities will be promptly addressed. You may view our full security policy here.


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