ffogarasi / redmine-api
Redmine API client
Requires
- php: >=5.4
- ext-curl: *
Requires (Dev)
- phpunit/phpunit: ~4.0
- dev-master
- v1.6.0
- v1.5.9
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4
- v1.3
- 1.2.x-dev
- v1.2.1
- v1.2
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.2
- 1.0.0
- 0.4.11
- 0.4.10
- 0.4.9
- 0.4.8
- 0.4.7
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2
- 0.1
- dev-checklists
- dev-bugfix-issueAttachments
- dev-params
This package is not auto-updated.
Last update: 2024-11-23 19:59:07 UTC
README
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
- Check header's response code (especially for POST/PUT/DELETE requests)
- See http://stackoverflow.com/questions/9183178/php-curl-retrieving-response-headers-and-body-in-a-single-request/9183272#9183272
- Maybe Guzzle for handling http connections
- https://github.com/guzzle/guzzle
Limitations
Redmine is missing some APIs for a full remote management of the data :
- List of activities & roles : http://www.redmine.org/issues/11464
- ...
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.4
- The PHP cURL extension
- The PHP SimpleXML extension
- The PHP JSON extension
- PHPUnit >= 4.0 (optional) to run the test suite
- "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
Composer
Composer users can simply run:
$ php composer.phar require kbsali/redmine-api:~1.0
at the root of their projects. To utilize the library, include
Composer's vendor/autoload.php
in the scripts that will use the
Redmine
classes.
For example,
<?php // This file is generated by Composer require_once 'vendor/autoload.php'; $client = new Redmine\Client('http://redmine.example.com', 'username', 'password');
Manual
It is also possible to install the library oneself, either locally to
a project or globally; say, in /usr/share/php
.
First, download and extract the library somewhere. For example, the
following steps extract v1.5.1 of the library into the
vendor/php-redmine-api-1.5.1
directory:
$ mkdir vendor $ wget -q https://github.com/kbsali/php-redmine-api/archive/v1.5.1.tar.gz $ tar -xf v1.5.1.tar.gz -C vendor/ $ rm v1.5.1.tar.gz
Now, in any scripts that will use the Redmine
classes, include the
lib/autoload.php
file from the php-redmine-api directory. For
example,
<?php // This file ships with php-redmine-api require 'vendor/php-redmine-api-1.5.1/lib/autoload.php'; $client = new Redmine\Client('http://redmine.example.com', 'username', 'password');
Running the test suite
If you have PHPUnit >= 4.0 installed, you can
run the test suite to make sure that the library will function
properly on your system. Simply run phpunit
in the php-redmine-api
directory. For example,
$ phpunit
PHPUnit 4.3.1 by Sebastian Bergmann.
Configuration read from ./phpunit.xml.dist
............................................................... 63 / 276 ( 22%)
............................................................... 126 / 276 ( 45%)
............................................................... 189 / 276 ( 68%)
............................................................... 252 / 276 ( 91%)
........................
Time: 591 ms, Memory: 10.50Mb
Basic usage of php-redmine-api
client
<?php // For Composer users (this file is generated by Composer) require_once 'vendor/autoload.php'; // Or if you've installed the library manually, use this instead. // require 'vendor/php-redmine-api-x.y.z/lib/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->user->all(); $client->user->listing(); $client->issue->create([ 'project_id' => 'test', 'subject' => 'some subject', 'description' => 'a long description blablabla', 'assigned_to' => 'user1', ]); $client->issue->all([ 'limit' => 1000 ]);
See example.php
for further examples.
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->time_entry->create($data); // remove impersonation for further calls $client->setImpersonateUser(null);
Thanks!
- Thanks to Thomas Spycher for the 1st version of the class.
- Thanks to Thibault Duplessis aka. ornicar for the php-github-api library, great source of inspiration!
- And all the contributors
- specially JanMalte for his impressive contribution to the test coverage! :)