zeichen32 / gitlabapibundle
Symfony Bundle to include the gitlab api.
Installs: 355 111
Dependents: 2
Suggesters: 1
Security: 0
Stars: 54
Watchers: 5
Forks: 16
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.2||^8.0
- m4tthumphrey/php-gitlab-api: ^11.0
- nyholm/psr7: ^1.0
- symfony/framework-bundle: ^4.4 || ^5.0 || ^6.0 || ^7.0
- symfony/http-client: ^4.4 || ^5.0 || ^6.0 || ^7.0
- symfony/http-client-contracts: ^1.0|^2.0|^3.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.2
- http-interop/http-factory-guzzle: ^1.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-11-10 19:53:44 UTC
README
This Bundle integrates the GitLab PHP API Client into your Symfony Project.
Step 1: Install Zeichen32GitLabApiBundle
The preferred way to install this bundle is to rely on Composer.
{ "require": { // ... "guzzlehttp/guzzle:^7.0.1", // Optional PSR Client, if you dont want to use the symfony http client "zeichen32/gitlabapibundle": "~6.1" } }
Step 2: Enable the bundle
Finally, enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Zeichen32\GitLabApiBundle\Zeichen32GitLabApiBundle(), ); }
Step 3: Configure Zeichen32GitLabApiBundle
Add Zeichen32GitLabApiBundle settings in app/config/config.yml:
zeichen32_git_lab_api: clients: firstclient: token: your-api-token url: http://example.org/api/v3/ auth_method: http_token secondclient: token: your-api-token url: http://example.org/api/v3/ auth_method: oauth_token sudo: 1 thirdclient: token: your-api-token url: http://example.org/api/v3/ alias: custom_alias
The first client automatically defined as your default client.
Step 4: Use the gitlab api
If you want to use the default client you can use type hinting.
<?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Gitlab\Client; class DefaultController extends AbstractController { public function index(Client $client) { $issues = $client->api('issues')->all($project_id); } }
If you want to get one of the other clients, you can get the specific client by the "zeichen32_gitlabapi.client.CLIENT_NAME" service id.
services: App\Controller\DefaultController: arguments: {$client: '@zeichen32_gitlabapi.client.default'}
<?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Gitlab\Client; class DefaultController extends AbstractController { private $client; public __construct(Client $client) { $this->client = $client; } public function index() { $issues = $this->client->api('issues')->all($project_id); } }
Or if you set alias option:
services: App\Controller\DefaultController: arguments: {$client: '@custom_alias'}
For more information about using the api, take a look at the GitLab Client Documentation.
Step 5: Configuration Reference
All available configuration options with their default values listed below:
zeichen32_git_lab_api: clients: # Required token: ~ # Required url: ~ # Required auth_method: ~ http_token|oauth_token sudo: ~ alias: ~ http_client: ~ # http client service id
License
This bundle is under the MIT license. See the complete license in the bundle:
Resources/meta/LICENSE