GitLab API client

9.12.0 2019-02-03 22:34 UTC


Build Status StyleCI Total Downloads Latest Stable Version Latest Unstable Version

Based on php-github-api and code from KnpLabs.


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.


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('')
    ->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN)

// or for OAuth2 (see
$client = \Gitlab\Client::create('')
    ->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('')
    ->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('')
    ->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


# 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

You get the idea! Take a look around (API methods, models) and please feel free to report any bugs.

Framework Integrations

If you have integrated GitLab into a popular PHP framework, let us know!


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.