bluestone/redmine-api

Redmine API client

v1.2.6 2023-11-09 21:56 UTC

This package is auto-updated.

Last update: 2024-12-10 00:21:54 UTC


README

Run tests Latest Stable Version

Installation

This package requires php:^8.1.
You can install it via composer:

composer require bluestone/redmine-api

Usage

First of all, you need to construct our service with a Guzzle client like this :

$httpHandler = new \Bluestone\Redmine\HttpHandler(
    baseUri: 'https://redmine.org'
);

$redmine = new \Bluestone\Redmine\Client($httpHandler);

Let's discuss all possibilities one by one.

Get projects

You can grab projects from Redmine API using this method :

$response = $redmine->project()->all();

foreach ($response->items as $project) {
    echo $project->name;
}

Get issues

You can grab issues from Redmine API using this method :

$response = $redmine->issue()->all();

foreach ($response->items as $issue) {
    echo $issue->subject;
}

Get project's versions

You can grab project's versions from Redmine API using this method :

$project = new \Bluestone\Redmine\Entities\Project([
    'id' => 42,
])

$response = $redmine->version()->all($project);

foreach ($response->items as $version) {
    echo $version->name;
}

Get time entries

You can grab time entries from Redmine API using this method :

$response = $redmine->timeEntry()->all();

foreach ($response->items as $timeEntry) {
    echo $timeEntry->hours;
}

Get specific issue

You can grab specific issue from Redmine API using this method :

$response = $redmine->issue()->get(1);

$issue = $response->items[0];

echo $issue->subject;

Update an issue

You can update an issue from Redmine API using this method :

$issue = new \Bluestone\Redmine\Entities\Issue([
    'id' => 1,
    'subject' => 'Hello from API',
    'project' => new Project(id: 1),
    'note' => 'Update an issue from API',
]);

$response = $redmine->issue()->update($issue);

if ($response->statusCode === 204) {
    echo "Well done !"
}

Contributing

Redmine API client is an open source project under MIT License and is open for contributions.