A Symfony2 bundle that integrates the Jira REST API into native Symfony2 services.
-
Install Composer.
# Install Composer curl -sS https://getcomposer.org/installer | php
-
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
-
After installing, you need to require Composer's autloader in the bootstrap of your project.
// app/autoload.php $loader = require __DIR__ . '/../vendor/autoload.php';
-
Add the bundle to your application kernel.
// app/AppKernel.php public function registerBundles() { return array( // ... new JiraApiBundle\JiraApiBundle(), // ... ); }
-
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"
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;
}
}
JiraApiBundle uses PHP Unit for unit testing.
-
Download PHP Unit.
# Download PHP Unit wget http://pear.phpunit.de/get/phpunit.phar chmod +x phpunit.phar
-
Make sure all dependencies are installed through Composer.
# Install dependencies php composer.phar install
-
Run the unit tests.
# Run unit tests php phpunit.phar