Code Monkey home page Code Monkey logo

gitlabapibundle's Introduction

Getting Started With Zeichen32GitLabApiBundle

Build Status

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.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: 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

gitlabapibundle's People

Contributors

20uf avatar emulienfou avatar endroid avatar janmikes avatar jeroeny avatar joshmiller83 avatar matth-- avatar webflo avatar zeichen32 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.