oveleon/youtrack-api-php

用于YouTrack REST API的PHP适配器

0.1.7 2024-06-24 10:12 UTC

This package is auto-updated.

Last update: 2024-08-24 10:47:53 UTC


README

此包是YouTrack REST API的PHP包装器。它允许与您的YouTrack实例进行通信。

安装

$ composer require oveleon/youtrack-api-php

入门指南

use Oveleon\YouTrack\Client;
use Oveleon\YouTrack\HttpClient\HttpClient;

// Create http client to use.
//  You can write your own adapter and use the HttpClientInterface to use e.g. the Guzzle HttpClient.
//  By default, the HttpClient of Symfony is used.
$httpClient = new HttpClient('https://example.myjetbrains.com', 'perm:your-token');

// Create api client
$api = new Client($httpClient);

// Get issues
$issues = $api->issues()
              ->all();

// Refine the query using the filter method
$issues = $api->issues()
              ->filter('state:resolved')
              ->all();

// Cool, but now we would like to specify the return fields...
$issues = $api->issues()
              ->fields(['summary', 'description'])
              ->filter('state:resolved')
              ->all();

// The query on a specific Project can also be refined in exactly the same way
$issues = $api->issues()
              ->filter('state:unresolved')
              ->project('PROJECT_ID');

// The predefined query `findByProject` does nothing more than define a filter for you (In YouTrack the
// filter is described as `query`), so you could also define the following filter to get the same result
$issues = $api->issues()
              ->filter('project:SampleProject')
              ->all();

// Use pagination...
$issues = $api->issues()
              ->paginate(0, 10)
              ->all();

// And now we use another endpoint
$projects = $api->projects()
                ->all();

// ...

文档

阅读完整的文档

参考

  • YouTrack REST API 文档
  • 使用Parsedown或其他Markdown解析器将问题描述等内容转换为HTML。
  • 基于此API的简单票据系统,用于开源CMS Contao

贡献

API目前仅支持可用选项的一个子集。基本结构已经准备就绪,以便于贡献和添加新端点。结构应该是自我解释的,但如果你有任何问题或评论,请提交问题。补充查询或新入口点必须作为拉取请求提供。

待办事项

  • 提供更多端点
  • 扩展现有端点(例如创建问题)
  • 文档