PHP code example of tzk / taiga-php

1. Go to this page and download the library: Download tzk/taiga-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tzk / taiga-php example snippets


// The API Url
$baseUrl = 'https://api.taiga.io/api/v1/';

// The credentials used for the authentification
$credentials = [
    'username' => 'USERNAME',
    'password' => 'PASSWORD',
    'type'    => 'normal'
];

echo generate_taiga_auth_token($baseUrl, $credentials);

$request = TZK\Taiga\CurlRequest();

$headers = [
    'language' => 'fr',
    'x-disable-pagination' => true
];

$taiga = new TZK\Taiga\Taiga($request, $baseUrl, $auth_token, $headers);

$taiga->setAcceptLanguage('fr')->setAuthorization('Bearer ' . $auth_token);

// In header_shortcuts.php
return [
    'language' => [
        'header' => 'Accept-Language',
    ],
    'authToken' => [
        'header' => 'Authorization',
        'prefix' => 'Bearer ',
    ],
];

// Will produce the same as the previous example.
$taiga->setLanguage('fr')->setAuthToken($token);



namespace TZK\Taiga\Services;

use TZK\Taiga\RestClient;
use TZK\Taiga\Service;

class IssueTypes extends Service
{
    public function __construct(RestClient $taiga)
    {
        parent::__construct($taiga, 'issue-types');
    }

    public function getList(array $param)
    {
        return $this->get(null, $param);
    }

    public function create(array $data)
    {
        return $this->post(null, [], $data);
    }

    public function getById($id)
    {
        return $this->get($id);
    }

    public function edit($id, array $data)
    {
        return $this->put($id, [], $data);
    }

    public function remove($id)
    {
        return $this->delete($id);
    }

    public function vote($id)
    {
        return $this->post(sprintf('%s/upvote', $id));
    }

    public function bulkUpdateOrder(array $data)
    {
        return $this->post('bulk_update_order', [], $data);
    }
}


// Access with the 'issueTypes' public method
$issues = $taiga->issueTypes()->getList(['project' => $projectId]);

// Access with the 'issues' public method
$issues = $taiga->issues()->create(['project' => $projectId, 'subject' => 'My super issue']);