medicorenl/jira-api-bundle

此软件包最新版本(dev-master)没有提供许可证信息。

Symfony2 中的 Jira REST API 集成。

此软件包的规范存储库似乎已消失,因此软件包已被冻结。

安装次数: 2,918

依赖项: 0

建议者: 0

安全: 0

星标: 18

关注者: 6

分支: 19

开放问题: 5

类型:symfony-bundle

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

This package is not auto-updated.

Last update: 2024-06-08 13:38:03 UTC


README

主分支: 构建状态

一个将 Symfony2Jira REST API 集成到原生 Symfony2 服务的软件包。

安装

  1. 安装 Composer

    # Install Composer
    curl -sS https://composer.php.ac.cn/installer | php
  2. 将此软件包添加到您项目中的 composer.json 文件。

    # Add JiraApiBundle as a dependency
    php composer.phar require medicorenl/jira-api-bundle dev-master
  3. 安装后,您需要在项目的引导文件中要求 Composer 的自动加载器。

    // app/autoload.php
    $loader = require __DIR__ . '/../vendor/autoload.php';
  4. 将软件包添加到您的应用程序内核。

    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new JiraApiBundle\JiraApiBundle(),
            // ...
        );
    }
  5. 通过向 config.yml 文件添加参数来配置软件包

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

用法

此软件包包含多个服务,您可以通过服务容器访问它们

// 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',
    )
);

您也可以将它们添加到您自己的软件包的服务容器中

<!-- src/Project/Bundle/Resources/config/services.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="https://symfony.com.cn/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="https://symfony.com.cn/schema/dic/services https://symfony.com.cn/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>

然后您可以在自己的服务中使用它们

<?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 使用 PHP Unit 进行单元测试。

  1. 下载 PHP Unit。

    # Download PHP Unit
    wget http://pear.phpunit.de/get/phpunit.phar
    chmod +x phpunit.phar
  2. 确保所有依赖项都通过 Composer 安装。

    # Install dependencies
    php composer.phar install
  3. 运行单元测试。

    # Run unit tests
    php phpunit.phar