muxx / redmine-api-client-php
Redmine的PHP API客户端
v0.2.1
2024-04-03 10:58 UTC
Requires
- php: ^8
- ext-json: *
- psr/http-client: ^1.0
- psr/http-client-implementation: *
- psr/http-factory: ^1.0
- psr/http-factory-implementation: *
Requires (Dev)
- nyholm/psr7: ^1.5
- php-http/mock-client: ^1.5
- phpunit/phpunit: ^9.6
README
PHP API客户端用于Redmine。
安装
请确保为psr/http-client-implementation
和psr/http-factory-implementation
提供实现。例如
composer require nyholm/psr7 guzzlehttp/guzzle
使用composer安装库
composer require muxx/redmine-api-client-php
Symfony
在HttpClient中启用PSR-18
services: Redmine\ApiClient: arguments: $url: 'https://redmine.somehost.com' $apiKey: 'some-api-key'
使用方法
require 'vendor/autoload.php'; $c = new Redmine\ApiClient( new HttpClient(), new Psr17Factory(), new Psr17Factory(), 'https://redmine.somehost.com', 'some-api-key' ); $response = $c->requestGet('projects/some-project/memberships'); foreach ($response['memberships'] as $membership) { if (isset($membership['user']['name'])) { echo sprintf("User: %s\n", $membership['user']['name']); } if (isset($membership['group']['name'])) { echo sprintf("Group: %s\n", $membership['group']['name']); } }