dev-master
9999999-devJira REST API integration in Symfony2.
The Requires
The Development Requires
by Salem Rabhi
rest symfony jira
Jira REST API integration in Symfony2.
A Symfony2 bundle that integrates the Jira REST API into native Symfony2 services., (*2)
Install Composer., (*3)
# Install Composer curl -sS https://getcomposer.org/installer | php
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
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';
Add the bundle to your application kernel., (*6)
// app/AppKernel.php public function registerBundles() { return array( // ... new JiraApiBundle\JiraApiBundle(), // ... ); }
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"
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; } }
JiraApiBundle uses PHP Unit for unit testing., (*11)
Download PHP Unit., (*12)
# Download PHP Unit wget http://pear.phpunit.de/get/phpunit.phar chmod +x phpunit.phar
Make sure all dependencies are installed through Composer., (*13)
# Install dependencies php composer.phar install
Run the unit tests., (*14)
# Run unit tests php phpunit.phar
Jira REST API integration in Symfony2.
rest symfony jira