2017 © Pedro Peláez
 

library taiga-php

A PHP wrapper for the Taiga.io API

image

tzk/taiga-php

A PHP wrapper for the Taiga.io API

  • Monday, March 19, 2018
  • by TZK-
  • Repository
  • 3 Watchers
  • 10 Stars
  • 1,789 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 5 Forks
  • 1 Open issues
  • 16 Versions
  • 1 % Grown

The README.md

TaigaPHP

Build Status Latest Stable Version Total Downloads License, (*1)

TaigaPHP is a PHP wrapper used to handle the Taiga.io API easily., (*2)

(If you want to use this library with Laravel 5.x, take a look at https://github.com/TZK-/TaigaLaravel), (*3)

Installation (Composer)

TaigaPHP has been written and tested for PHP >=5.5 and and earlier versions. The only constraint is to have the cURL extension enabled., (*4)

To install the library, just run the command below:, (*5)

composer require tzk/taiga-php

Authentication

To send HTTP request to the API, you'll need to generate an Auth token., (*6)

The wrapper has a function to help you and you can just do like the code below or see https://taigaio.github.io/taiga-doc/dist/api.html#_authentication:, (*7)

// 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);

Get Taiga instance

$request = TZK\Taiga\CurlRequest();

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

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

Change configuration on the fly

You can change the configuration through HTTP headers on the fly., (*8)

You just need to call magic method which has the same name as the header you wanna set prefixed by 'set'., (*9)

Some headers are composed by multiple words separated by dashed (Ex. Accept-Language)., (*10)

To get it works, you should write the header name without dashes and in a camel-case format., (*11)

Example

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

To ease changing auth token or language on the fly, you can use shortcuts specified in src/config/header_shortcuts.php, (*12)

// 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);

Register a new service

The wrapper is based on 'Services' which wrap the API calls., (*13)

<?php

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);
    }
}

As you can see, it is very simple to add your own methods and interact with the API itself., (*14)

If you wanna add new services, the only thing you have to do is to create a new class inside the Service folder and extends the TZK\Taiga\Service class., (*15)

TaigaPHP will automatically load the service for you and it will be accessible from a public method which has the same name as your service., (*16)

Examples

Get issue types

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

Create a new issue

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

Supported features

  • Applications
  • Application Tokens
  • Epics
  • Issues
  • Issue Statuses
  • Issue Types
  • Priorities
  • Projects
  • Resolver
  • Severities
  • Users
  • UserStories

Tests

The library has been tested with Kahlan. If you want to run tests just run the command:, (*17)

./vendor/bin/kahlan

At the moment, the tests are covering the main fatures of the wrapper., (*18)

Contributing

TaigaPHP offers a great starting coverage, but there are some endpoints/tests missing., (*19)

If you use this wrapper, feel free to share if you have found bugs or added new endpoints / features or tests by opening a new PR., (*20)

The Versions

19/03 2018

dev-feature/attachments

dev-feature/attachments

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

The Development Requires

27/11 2017

dev-master

9999999-dev

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

The Development Requires

27/11 2017

v2.0.4

2.0.4.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

The Development Requires

29/10 2017

v2.0.3

2.0.3.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

The Development Requires

09/10 2017

v2.0.2

2.0.2.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

The Development Requires

08/10 2017

v2.0.1

2.0.1.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

The Development Requires

27/09 2017

v2.0.0

2.0.0.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

The Development Requires

26/04 2017

v1.1.0

1.1.0.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

12/04 2017

v1.0.7

1.0.7.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

08/04 2017

v1.0.6

1.0.6.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

08/04 2017

v1.0.5

1.0.5.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

08/04 2017

v1.0.4

1.0.4.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

28/11 2016

v1.0.3

1.0.3.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

24/11 2016

v1.0.2

1.0.2.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

23/11 2016

v1.0.1

1.0.1.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires

 

09/07 2016

v1.0

1.0.0.0

A PHP wrapper for the Taiga.io API

  Sources   Download

MIT

The Requires