caherrera / php-gitlab-api
GitLab API v4 client for PHP
Fund package maintenance!
GrahamCampbell
Requires
- php: ^7.2.5 || ^8.0
- ext-json: *
- ext-xml: *
- php-http/cache-plugin: ^1.7.1
- php-http/client-common: ^2.3
- php-http/discovery: ^1.12
- php-http/httplug: ^2.2
- php-http/multipart-stream-builder: ^1.1.2
- psr/cache: ^1.0
- psr/http-client-implementation: ^1.0
- psr/http-factory-implementation: ^1.0
- psr/http-message: ^1.0
- symfony/options-resolver: ^3.4 || ^4.0 || ^5.0
- symfony/polyfill-php80: ^1.17
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4.1
- guzzlehttp/guzzle: ^7.2
- http-interop/http-factory-guzzle: ^1.0
- 11.5.x-dev
- 11.4.x-dev
- 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.5.x-dev
- 10.5.0
- 10.4.x-dev
- 10.4.1.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
- dev-10.4-dev
This package is auto-updated.
Last update: 2024-11-15 08:04:20 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.2-8.0. 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.4" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"
Framework Integration
Laravel:
$ composer require "graham-campbell/gitlab:^5.2" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"
Symfony:
$ composer require "zeichen32/gitlabapibundle:^6.0" "symfony/http-client:^5.2" "nyholm/psr7:^1.3"
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 graham@alt-three.com. 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).