Skip to content

thinhhung/php-redmine-api

 
 

Repository files navigation

PHP Redmine API

A simple Object Oriented wrapper for Redmine API, written with PHP5.

Uses Redmine API.

Features

  • Follows PSR-0 conventions and coding standard: autoload friendly
  • API entry points implementation state :
  • OK Attachments
  • OK Groups
  • OK Custom Fields
  • OK Issues
  • OK Issue Categories
  • OK Issue Priorities
  • NOK Issue Relations - only partially implemented
  • OK Issue Statuses
  • OK News
  • OK Projects
  • OK Project Memberships
  • OK Queries
  • OK Roles
  • OK Time Entries
  • OK Time Entry Activities
  • OK Trackers
  • OK Users
  • OK Versions
  • OK Wiki

Todo

Limitations

Redmine is missing some APIs for a full remote management of the data :

A possible solution to this would be to create an extra APIs implementing the missing entry points. See existing effort in doing so : https://github.com/rschobbert/redmine-miss-api

Requirements

  • PHP >= 5.3.2 with cURL extension,
  • "Enable REST web service" for your Redmine project (/settings/edit?tab=authentication)
  • then obtain your API access key in your profile page : /my/account
  • or use your username & password

Install

Through composer, simply run :

$ php composer.phar require kbsali/redmine-api:~1.0

Basic usage of php-redmine-api client

<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';

$client = new Redmine\Client('http://redmine.example.com', 'API_ACCESS_KEY');
//-- OR --
$client = new Redmine\Client('http://redmine.example.com', 'username', 'password');

$client->api('user')->all();
$client->api('user')->listing();

$client->api('issue')->create([
    'project_id'  => 'test',
    'subject'     => 'some subject',
    'description' => 'a long description blablabla',
    'assigned_to' => 'user1',
]);
$client->api('issue')->all([
    'limit' => 1000
]);

see example.php

User Impersonation

As of Redmine V2.2 you can impersonate user through the REST API :

$client = new Redmine\Client('http://redmine.example.com', 'API_ACCESS_KEY');

// impersonate user
$client->setImpersonateUser('jsmith');

// create a time entry for jsmith
$client->api('time_entry')->create($data);

// remove impersonation for further calls
$client->setImpersonateUser(null);

Thanks!

About

A simple PHP Redmine API client, Object Oriented

Resources

License

Stars

Watchers

Forks

Packages

No packages published