m4tthumphrey / php-gitlab-api
GitLab API v4 client for PHP
Fund package maintenance!
GrahamCampbell
Installs: 4 123 878
Dependents: 69
Suggesters: 3
Security: 0
Stars: 933
Watchers: 30
Forks: 453
Open Issues: 37
Requires
- php: ^7.4.15 || ^8.0.2
- ext-json: *
- ext-xml: *
- php-http/cache-plugin: ^1.8.1 || ^2.0
- php-http/client-common: ^2.7.1
- php-http/discovery: ^1.19.2
- php-http/httplug: ^2.4
- php-http/multipart-stream-builder: ^1.3
- psr/cache: ^1.0 || ^2.0 || ^3.0
- psr/http-client-implementation: ^1.0
- psr/http-factory-implementation: ^1.0
- psr/http-message: ^1.1 || ^2.0
- symfony/options-resolver: ^4.4 || ^5.0 || ^6.0 || ^7.0
- symfony/polyfill-php80: ^1.26
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8.2
- guzzlehttp/guzzle: ^7.8
- http-interop/http-factory-guzzle: ^1.2
- 11.15.x-dev
- 11.14.x-dev
- 11.14.0
- 11.13.x-dev
- 11.13.0
- 11.12.x-dev
- 11.12.0
- 11.11.x-dev
- 11.11.1
- 11.11.0
- 11.10.x-dev
- 11.10.1
- 11.10.0
- 11.9.x-dev
- 11.9.1
- 11.9.0
- 11.8.x-dev
- 11.8.0
- 11.7.x-dev
- 11.7.1
- 11.7.0
- 11.6.x-dev
- 11.6.0
- 11.5.x-dev
- 11.5.1
- 11.5.0
- 11.4.x-dev
- 11.4.1
- 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.4.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
This package is auto-updated.
Last update: 2024-12-17 23:18:33 UTC
README
We present a modern GitLab API v4 client for PHP.
This is strongly based on php-github-api by KnpLabs. With this in mind, we now have very similar clients for:
- Bitbucket - bitbucket/client by Graham Campbell.
- GitHub - knplabs/github-api by KnpLabs.
- GitLab - m4tthumphrey/php-gitlab-api which is this package!
Check out the change log, releases, security policy, license, code of conduct, and contribution guidelines.
Installation
This version supports PHP 7.4-8.3. 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:^11.14" \ "guzzlehttp/guzzle:^7.8" "http-interop/http-factory-guzzle:^1.2"
Framework Integration
Laravel:
$ composer require "graham-campbell/gitlab:^7.5"
Symfony:
$ composer require "zeichen32/gitlabapibundle:^6.1"
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
// 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, ]);
Self-Hosted GitLab
$client = new Gitlab\Client(); $client->setUrl('https://git.yourdomain.com'); $client->authenticate('your_http_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 hello@gjcampbell.co.uk. 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).