rastor / jira-client
A simple PHP JIRA REST client
Installs: 59 963
Dependents: 0
Suggesters: 0
Security: 0
Stars: 20
Watchers: 3
Forks: 18
Open Issues: 9
Requires
- guzzlehttp/guzzle: ~5.0|~6.0|~7.0
This package is auto-updated.
Last update: 2024-11-04 20:30:16 UTC
README
A simple JIRA REST client for PHP.
The main or killing feature of this library is resolving custom fields of issues.
Example
$api = new JiraClient\JiraClient('http://jira.hostname', 'login', 'password'); try { // Get an existing issue $issue = $api->issue()->get('JRA-123'); // Print the issue id. echo $issue->getId(); // Print the issue key. echo $issue->getKey(); // Create new issue. $newIssue = $api->issue() ->create('JIRA', 'Suggestion') ->field(Field::SUMMARY, 'My Suggestion') ->field(Field::DESCRIPTION, 'Some description') ->execute(); // Print the issue id. echo $newIssue->getId(); $newIssue = $newIssue->update() ->field(Field::DESCRIPTION, 'Some new description') ->customField(10012, 'Value for custom field') ->fieldAdd(Field::LABELS, 'new-label') ->execute(); // Print description of updated issue. echo $newIssue->getDescription(); // Two ways for adding new comment. $newIssue->addComment("Some comment content"); $api->issue()->addComment($newIssue->getKey(), "Another comment content"); // Add new comment limited to the developer role. $newIssue->addComment("Only for developers", "role", "Developers"); // Get reporter's name. $reporterName = $newIssue->getReporter()->getName(); // Get an array of labels. $labels = $newIssue->getLabels(); // Get an array of transitions for issue $transitions = $api->issue()->getTransitions($newIssue->getKey()); // Executing transitions to change issue status $newIssue->transition()->execute(120); // Searches for issues using JQL $issues = new JiraClient\Request\SearchIterator($api, "project = Test"); // or another way $issues = $api->issue()->search("project = Test"); // Total count of found issues $total = $issues->getTotal(); foreach ($issues as $issue) { $issue->update() ->fieldAdd(Field::LABELS, 'new-label') ->execute(); } } catch (\JiraClient\Exception\JiraException $e) { // exception processing }
Installation
composer require "rastor/jira-client:~0.4"