zeichen32/gitlabapibundle

Symfony2 Bundle to include the gitlab api.

Installs: 3 117

Dependents: 0

Stars: 8

Watchers: 2

Forks: 2

Language: PHP

v2.1.2 2015-03-07 13:44 UTC

README

Build Status

This Bundle integrate the Gitlab API Wrapper into your Symfony2 Project.

Attention: I have refactor the whole bundle and have remove the issue tracker to decouple the issue tracker from the bundle. The old version with the issue tracker is still available in the 1.0.x Branche

Step 1: Install Zeichen32GitLabApiBundle

The preferred way to install this bundle is to rely on Composer.

{
    "require": {
        // ...
        "zeichen32/gitlabapibundle": "~2.0"
    }
}

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: url_token
        secondclient:
            token: your-api-token
            url: http://example.org/api/v3/
            auth_method: http_token
            sudo: 1
            options:
                timeout: 60
                user_agent: MyApp (http://example.org)
        thirdclient:
            token: your-api-token
            url: http://example.org/api/v3/
            alias: custom_alias

The first client is defined automatically as your default client.

Step 4: Use the gitlab api

If you want to use the default client, you can easy getting the client by the "gitlab_api" service-id.

        $api = $this->get('gitlab_api');
        $issues = $api->api('issues')->all($project_id);

If you want to get one of the other clients, you can getting the specific client by the "zeichen32_gitlabapi.client.CLIENT_NAME" service id.

        $api = $this->get('zeichen32_gitlabapi.client.secondclient');
        $issues = $api->api('issues')->all($project_id);

Or if you set alias option:

        $api = $this->get('custom_alias');
        $issues = $api->api('issues')->all($project_id);

For more information about using the api, take a look at the Gitlab Client Documentation.

Step 5: Configuration Reference

All available configuration options are listed below with their default values.

zeichen32_git_lab_api:
    clients:              # Required
        token:                ~ # Required
        url:                  ~ # Required
        auth_method:          ~ http_token|url_token|oauth_token
        sudo:                 ~
        alias:                ~
        http_client:          ~ # Buzz client service id
        options:
            timeout:            ~
            user_agent:         ~

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE