PHP code example of spacetab-io / jira-sdk-php

1. Go to this page and download the library: Download spacetab-io/jira-sdk-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/ */

    

spacetab-io / jira-sdk-php example snippets


use Amp\Loop;
use Psr\Log\LogLevel;
use Spacetab\Logger\Logger;
use Spacetab\SDK\Jira\Cache;
use Spacetab\SDK\Jira\Client;
use Spacetab\SDK\Jira\Configurator;
use Spacetab\SDK\Jira\Exception;

Loop::run(function () {
    $logger = Logger::default('Client', LogLevel::DEBUG);

    $configurator = Configurator::fromBasicAuth('https://jira.server.com', 'username', 'jiraTokenStringOrPassword');
    $configurator->setLogger($logger);
    $configurator->setCache(Cache::enabled());
    $configurator->configurate();

    $jira = new Client($configurator);

    try {
        $issue = yield $jira->issue()->get('KEY-1');
    } catch (Exception\Main $e) {
        //$e->getMessage();
        //$e->getErrorMessages();
    }

    dump($issue);
});

use Amp\Loop;
use Spacetab\SDK\Jira\Client;
use Spacetab\SDK\Jira\Configurator;

Loop::run(function () {
    $configurator = Configurator::fromBasicAuth('https://jira.server.com', 'username', 'jiraTokenStringOrPassword');
    $configurator->configurate();

    $jira = new Client($configurator);
    $iterator = $jira->search()->query('project = KEY', ['summary'], 20);

    $results = [];
    while (yield $iterator->advance()) {
        $results[] = $iterator->getCurrent();
    }

    dump($results);
});