PHP code example of bluestone / redmine-api

1. Go to this page and download the library: Download bluestone/redmine-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bluestone / redmine-api example snippets


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

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

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

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

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

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

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

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

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



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

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

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

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

echo $issue->subject;

$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 !"
}