medicorenl/jira-api-bundle

There is no license information available for the latest version (dev-master) of this package.

Jira REST API integration in Symfony2.

Installs: 2 918

Dependents: 0

Suggesters: 0

Security: 0

Stars: 18

Watchers: 7

Forks: 20

Open Issues: 5

Type:symfony-bundle

dev-master 2017-01-20 11:30 UTC

This package is not auto-updated.

Last update: 2024-04-13 12:48:33 UTC


README

Master: Build Status

A Symfony2 bundle that integrates the Jira REST API into native Symfony2 services.

Installation

  1. Install Composer.

    # Install Composer
    curl -sS https://getcomposer.org/installer | php
  2. Add this bundle to the composer.json file of your project.

    # Add JiraApiBundle as a dependency
    php composer.phar require medicorenl/jira-api-bundle dev-master
  3. After installing, you need to require Composer's autloader in the bootstrap of your project.

    // app/autoload.php
    $loader = require __DIR__ . '/../vendor/autoload.php';
  4. Add the bundle to your application kernel.

    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new JiraApiBundle\JiraApiBundle(),
            // ...
        );
    }
  5. Configure the bundle by adding parameters to the config.yml file:

    # app/config/config.yml
        jira_api:
            url:         "http://jira.your-organisation.com/jira/rest/api/latest/"
            credentials: "username:password"

Usage

This bundle contains a number of services, to access them through the service container:

// Get a particulair Jira issue from the JiraApiBundle\Service\IssueService
$issueService = $this->get('jira_api.issue');
$issueService->get('STORY-KEY');

// Get all issues by a project in the JiraApiBundle\Service\ProjectService
$projectService = $this->get('jira_api.project');
$projectService->getAll();

// Search for a issue in the JiraApiBundle\Service\SearchService
$searchService = $this->get('jira_api.search');
$searchService->search(
    array(
        'jql' => 'assignee=fred+order+by+duedate',
    )
);

You can also add them to the service container of your own bundle:

<!-- src/Project/Bundle/Resources/config/services.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services$
    <services>
        <service id="myproject.myservice" class="MyProject\MyBundle\Services\MyService.php" public="true">
            <argument type="service" id="jira_api.issue" />
            <argument type="service" id="jira_api.project" />
            <argument type="service" id="jira_api.search" />
        </service>
    </services>
</container>

You can then use them in your own services

<?php

namespace Project\Bundle\Services;

use JiraApiBundle\Service\IssueService;
use JiraApiBundle\Service\ProjectService;
use JiraApiBundle\Service\SearchService;

/**
 * Service class for my bundle.
 */
class MyService
{
    /**
     * @var \JiraApiBundle\Service\IssueService
     */
    private $issueService;

    /**
     * @var \JiraApiBundle\Service\ProjectService
     */
    private $projectService;

    /**
     * @var \JiraApiBundle\Service\SearchService
     */
    private $searchService;

    /**
     * Constructor.
     *
     * @param \JiraApiBundle\Service\IssueService   $issueService
     * @param \JiraApiBundle\Service\ProjectService $projectService
     * @param \JiraApiBundle\Service\SearchService  $searchService
     */
    public function __construct(
        IssueService   $issueService,
        ProjectService $projectService,
        SearchService  $searchService,
    ) {
        $this->issueService   = $issueService;
        $this->projectService = $projectService;
        $this->searchService  = $searchService;
    }
}

Unit testing

JiraApiBundle uses PHP Unit for unit testing.

  1. Download PHP Unit.

    # Download PHP Unit
    wget http://pear.phpunit.de/get/phpunit.phar
    chmod +x phpunit.phar
  2. Make sure all dependencies are installed through Composer.

    # Install dependencies
    php composer.phar install
  3. Run the unit tests.

    # Run unit tests
    php phpunit.phar