2017 © Pedro Peláez
 

symfony-bundle jira-api-bundle

Jira REST API integration in Symfony2.

image

rabhisalem/jira-api-bundle

Jira REST API integration in Symfony2.

  • Wednesday, February 15, 2017
  • by rebhisalem
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 26 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

JiraApiBundle

Master: Build Status, (*1)

A Symfony2 bundle that integrates the Jira REST API into native Symfony2 services., (*2)

Installation

  1. Install Composer., (*3)

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

    # 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., (*5)

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

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

    # 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:, (*8)

// 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:, (*9)

<!-- 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, (*10)

<?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., (*11)

  1. Download PHP Unit., (*12)

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

    # Install dependencies
    php composer.phar install
    
  3. Run the unit tests., (*14)

    # Run unit tests
    php phpunit.phar
    

The Versions

15/02 2017

dev-master

9999999-dev

Jira REST API integration in Symfony2.

  Sources   Download

The Requires

 

The Development Requires

by Salem Rabhi

rest symfony jira