xen3r0 / jira-api-client
A Modern Jira API client
Requires
- php: ^8.1
- ext-dom: *
- ext-json: *
- ext-xml: *
- phpdocumentor/reflection-docblock: ^5.6.2
- phpstan/phpdoc-parser: ^2.2.0
- symfony/http-client: ^6.4 || ^7.0
- symfony/property-access: ^6.4 || ^7.0
- symfony/property-info: ^6.4 || ^7.0
- symfony/serializer: ^6.4 || ^7.0
- xen3r0/adf-tools: ^1.1.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.85
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^10.0
- symfony/framework-bundle: ^6.4 || ^7.0
- symfony/var-dumper: ^6.4
README
Jira API Client is a modern PHP library that provides a simple and fluent interface to interact with the Jira API.
Getting started
Prerequisites
This library requires PHP 8.1 or higher and the following PHP extensions:
domjsonxml
Installation
Add xen3r0/jira-api-client to your composer.json file:
php composer.phar require xen3r0/jira-api-client
Usage
Create a new instance of the JiraClient class:
use Xen3r0\JiraApiClient\Configuration\ConfigurationFactory; use Xen3r0\JiraApiClient\Http\JiraClient; $configuration = ConfigurationFactory::create([ 'host' => 'https://your-jira-instance.atlassian.net', 'username' => 'your-username', 'password' => 'your-api-token', ]); $client = new JiraClient($configuration);
Now, you can use some repositories, for example, IssueRepository:
use Xen3r0\JiraApiClient\Repository\IssueRepository; $issueRepository = new IssueRepository($client); $issue = $issueRepository->findByIdOrKey('PROJECT-123');
Symfony Bundle
You can also use this library as a Symfony bundle, you don't need to add another package to your composer dependencies.
Registering the Bundle
To register the bundle, add it to your config/bundles.php file:
return [ // ... Xen3r0\JiraApiClient\Symfony\Bundle\JiraApiClientBundle::class => ['all' => true], ];
Configuration
Then, configure the bundle in your config/packages/jira_api_client.yaml file:
jira_api_client: host: 'https://your-jira-instance.atlassian.net' username: 'your-username' password: 'your-api-token'
Usage
You can now use every repository as a service in your Symfony application. For example, to use the IssueRepository:
use Xen3r0\JiraApiClient\Repository\IssueRepositoryInterface; #[Route('/some-route', name: 'some_route')] class SomeController { public function __construct( private readonly IssueRepositoryInterface $issueRepository, ) { $this->issueRepository = $issueRepository; } public function __invoke(): void { $issue = $this->issueRepository->findByIdOrKey('PROJECT-123'); // Do something with the issue... } }
Repositories
This library provides several repositories to interact with different Jira API endpoints. Here are some of the available repositories:
CustomFieldOptionRepository: Manage custom field options in Jira.IssueCommentRepository: Manage comments on issues in Jira.IssueRepository: Manage issues in Jira.ProjectRepository: Manage projects in Jira.VersionRepository: Manage versions in Jira.
A repository is missing ? You can suggest a new repository by opening an issue and/or pull request.
Contributing
See the CONTRIBUTING.md file for details on how to contribute to this project.
Credits
License
This project is licensed under the MIT License - see the LICENSE file for details