redmine php版,A simple PHP Redmine API client, Object Oriented

PHP Redmine API 是一个遵循 PSR-0 规范的库,用于与 Redmine API 交互。它支持如用户、问题、时间条目等资源的操作。要使用此库,需要启用 Redmine 项目的 REST web 服务,并获取 API 访问密钥。可以通过 Composer 或手动安装。此外,还提供了测试套件以确保兼容性。
摘要由CSDN通过智能技术生成

PHP Redmine API

A simple PHP Object Oriented wrapper for 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.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,

// 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.18 of the library into the

vendor/php-redmine-api-1.5.18 directory:

$ mkdir vendor

$ wget -q https://github.com/kbsali/php-redmine-api/archive/v1.5.18.tar.gz

$ tar -xf v1.5.18.tar.gz -C vendor/

$ rm v1.5.18.tar.gz

Now, in any scripts that will use the Redmine classes, include the

src/autoload.php file from the php-redmine-api directory. For

example,

// This file ships with php-redmine-api

require 'vendor/php-redmine-api-1.5.18/src/autoload.php';

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

Running the test suite

You can run test suite to make sure the library will work properly on your system. Simply run vendor/bin/phpunit in the project's directory :

$ vendor/bin/phpunit

PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

Error: No code coverage driver is available

............................................................... 63 / 285 ( 22%)

............................................................... 126 / 285 ( 44%)

............................................................... 189 / 285 ( 66%)

............................................................... 252 / 285 ( 88%)

................................. 285 / 285 (100%)

Time: 107 ms, Memory: 8.00MB

OK (285 tests, 662 assertions)

Basic usage of php-redmine-api client

// 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/src/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_id' => 123, // or '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!

specially JanMalte for his impressive contribution to the test coverage! :)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值