{"id":13404786,"url":"https://github.com/kbsali/php-redmine-api","last_synced_at":"2025-12-26T23:56:57.612Z","repository":{"id":4844888,"uuid":"5999131","full_name":"kbsali/php-redmine-api","owner":"kbsali","description":"A simple PHP Redmine API client, Object Oriented","archived":false,"fork":false,"pushed_at":"2024-04-09T08:18:07.000Z","size":1515,"stargazers_count":419,"open_issues_count":22,"forks_count":220,"subscribers_count":38,"default_branch":"v2.x","last_synced_at":"2024-04-17T09:24:35.753Z","etag":null,"topics":["api-client","composer-package","looking-for-maintainer","maintainer-wanted","php","redmine"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Coderockr/parse.com-php-library","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kbsali.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-09-28T15:23:10.000Z","updated_at":"2024-06-13T03:25:23.822Z","dependencies_parsed_at":"2024-03-05T04:27:34.972Z","dependency_job_id":"b678ce0c-a6e6-4123-b835-07948bcc9950","html_url":"https://github.com/kbsali/php-redmine-api","commit_stats":{"total_commits":471,"total_committers":95,"mean_commits":4.957894736842105,"dds":0.7940552016985138,"last_synced_commit":"a2e59e7ac9e899fa349666ca0d482b5d7d18a146"},"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbsali%2Fphp-redmine-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbsali%2Fphp-redmine-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbsali%2Fphp-redmine-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbsali%2Fphp-redmine-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kbsali","download_url":"https://codeload.github.com/kbsali/php-redmine-api/tar.gz/refs/heads/v2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243554056,"owners_count":20309858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","composer-package","looking-for-maintainer","maintainer-wanted","php","redmine"],"created_at":"2024-07-30T19:01:51.422Z","updated_at":"2025-12-26T23:56:57.606Z","avatar_url":"https://github.com/kbsali.png","language":"PHP","funding_links":[],"categories":["PHP","API wrapper"],"sub_categories":["Commercial Themes"],"readme":"# PHP Redmine API\n\n[![Latest Version](https://img.shields.io/github/release/kbsali/php-redmine-api.svg)](https://github.com/kbsali/php-redmine-api/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-blueviolet.svg)](LICENSE)\n[![Build Status](https://github.com/kbsali/php-redmine-api/actions/workflows/tests.yml/badge.svg?branch=v2.x)](https://github.com/kbsali/php-redmine-api/actions)\n[![Codecov](https://codecov.io/gh/kbsali/php-redmine-api/graph/badge.svg?token=4P6dAaDbJ9)](https://codecov.io/gh/kbsali/php-redmine-api)\n[![Total Downloads](https://img.shields.io/packagist/dt/kbsali/redmine-api.svg)](https://packagist.org/packages/kbsali/redmine-api)\n\nA simple PHP Object Oriented wrapper for Redmine API.\n\nUses [Redmine API](https://www.redmine.org/projects/redmine/wiki/Rest_api/).\n\n## Features\n\n* Follows PSR-4 conventions and coding standard: autoload friendly\n* Choose between using native `cURL` function or any\n[PSR-18 HTTP client implementation ](https://packagist.org/providers/psr/http-client-implementation)\nlike [Guzzle](https://github.com/guzzle/guzzle) for handling http connections\n* [mid-level API](docs/usage.md#mid-level-api) e.g.\n    ```php\n    $client-\u003egetApi('issue')-\u003ecreate(['project_id' =\u003e 1, 'subject' =\u003e 'issue title']);\n\n    $response = $client-\u003egetApi('issue')-\u003egetLastResponse();\n    ```\n* [low-level API](docs/usage.md#low-level-api) e.g.\n    ```php\n    $response = $client-\u003erequest(\n        HttpFactory::makeJsonRequest(\n            'POST',\n            '/issues.json',\n            '{\"issue\":{\"project_id\":1,\"subject\":\"issue title\"}}',\n        ),\n    );\n    ```\n\n## Supported Redmine versions\n\nWe support (and run tests against) the [latest supported Redmine versions](https://www.redmine.org/projects/redmine/wiki/Download#Versions-status-and-releases-policy)\nthat receive security updates.\n\n- Redmine 6.1.x\n- Redmine 6.0.x\n- Redmine 5.1.x\n\nNevertheless, you can also use this library for all older Redmine versions.\nIn this case, however, be aware that some features might not be supported by your Redmine server.\n\nIf a new Redmine version enables new features that are not yet supported with this library,\nyou are welcome to [create an issue](https://github.com/kbsali/php-redmine-api/issues).\n\n## Requirements\n\n* PHP ^7.4 || ^8.0\n* The PHP [SimpleXML](https://php.net/manual/en/book.simplexml.php) extension\n* The PHP [JSON](https://php.net/manual/en/book.json.php) extension\n* Enabled REST web service on your Redmine server\n    * Go to Administration -\u003e Settings -\u003e Api (`/settings/edit?tab=api`) and check the \"Enable REST web service\" box\n    * Obtain your *API access key* in your profile page: `/my/account`\n    * (or use your *username \u0026 password*; not recommended)\n\n### Optional\n\n* The PHP [cURL](https://php.net/manual/en/book.curl.php) extension if you want to use the native `cURL` functions.\n* [PHPUnit](https://phpunit.de/) \u003e= 9.0 (optional) to run the test suite\n\n## Todo\n\n* Tracking of Redmine API feature support in [#305](https://github.com/kbsali/php-redmine-api/issues/305)\n* Check header's response code (especially for POST/PUT/DELETE requests)\n    * See https://stackoverflow.com/questions/9183178/php-curl-retrieving-response-headers-and-body-in-a-single-request/9183272#9183272\n\n## Limitations / Missing Redmine-API\n\nRedmine is missing some APIs for a full remote management of the data:\n\n* List of activities \u0026 roles: https://www.redmine.org/issues/11464\n* [Open issues because of missing Redmine API](https://github.com/kbsali/php-redmine-api/labels/pending%3A%20missing%20api)\n\n## Install\n\nBy using [Composer](https://getcomposer.org/) you can simply run:\n\n```bash\n$ php composer.phar require kbsali/redmine-api\n```\n\nat the root of your projects. To utilize the library, include\nComposer's `vendor/autoload.php` in the scripts that will use the\n`Redmine` classes.\n\nFor example,\n\n```php\n\u003c?php\n// This file is generated by Composer\nrequire_once 'vendor/autoload.php';\n\n$client = new \\Redmine\\Client\\NativeCurlClient('https://redmine.example.com', '0ef19567656532f8dd43a4dbfeda787f01f3e659');\n```\n\nFor a manual installation please follow this [instruction](https://github.com/kbsali/php-redmine-api/pull/285#issuecomment-856609296).\n\n### Running the test suite\n\nYou 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 :\n\n```\n$ vendor/bin/phpunit\nPHPUnit 9.5.4 by Sebastian Bergmann and contributors.\n\nWarning:       No code coverage driver available\n\n...............................................................  63 / 432 ( 14%)\n............................................................... 126 / 432 ( 29%)\n............................................................... 189 / 432 ( 43%)\n............................................................... 252 / 432 ( 58%)\n............................................................... 315 / 432 ( 72%)\n............................................................... 378 / 432 ( 87%)\n......................................................          432 / 432 (100%)\n\nTime: 00:00.149, Memory: 14.00 MB\n\nOK (432 tests, 1098 assertions)\n```\n\n## Basic usage of `php-redmine-api` client\n\n### Start your project\n\nCreate your project e.g. in the `index.php` by require the `vendor/autoload.php` file.\n\n```diff\n+\u003c?php\n+\n+require_once 'vendor/autoload.php';\n```\n\n### Instantiate a Redmine Client\n\nYou can choose between:\n\n1. a native curl client or\n2. the PSR-18 compatible client.\n\n#### 1. Native curl Client `Redmine\\Client\\NativeCurlClient`\n\n\u003e :bulb: This client was introduced in `php-redmine-api` v1.8.0. If you are\n\u003e using the old `Redmine\\Client` please [see this migration guide for help to\n\u003e upgrade your code](docs/migrate-to-nativecurlclient.md).\n\nYou will need a URL to your Redmine instance and either a valid Apikey...\n\n```diff\n\u003c?php\n\nrequire_once 'vendor/autoload.php';\n+\n+// Instantiate with ApiKey\n+$client = new \\Redmine\\Client\\NativeCurlClient('https://redmine.example.com', '1234567890abcdfgh');\n```\n\n... or valid username/password.\n\n```diff\n\u003c?php\n\nrequire_once 'vendor/autoload.php';\n+\n+// Instantiate with Username/Password (not recommended)\n+$client = new \\Redmine\\Client\\NativeCurlClient('https://redmine.example.com', 'username', 'password');\n```\n\n\u003e :bulb: For security reason it is recommended that you use an ApiKey rather than your username/password.\n\n##### cURL configuration\n\nAfter you instantiate a client you can set some optional `cURL` settings.\n\n```diff\n\u003c?php\n\nrequire_once 'vendor/autoload.php';\n\n// Instantiate with ApiKey\n$client = new Redmine\\Client\\NativeCurlClient('https://redmine.example.com', '1234567890abcdfgh');\n+\n+// [OPTIONAL] if you want to check the servers' SSL certificate on Curl call\n+$client-\u003esetCurlOption(CURLOPT_SSL_VERIFYPEER, true);\n+\n+// [OPTIONAL] set the port (it will try to guess it from the url)\n+$client-\u003esetCurlOption(CURLOPT_PORT, 8080);\n+\n+// [OPTIONAL] set a custom host\n+$client-\u003esetCurlOption(CURLOPT_HTTPHEADER, ['Host: https://custom.example.com']);\n\n```\n#### 2. Psr-18 compatible Client `Redmine\\Client\\Psr18Client`\n\n\u003e :bulb: This client was introduced in `v1.7.0` of this library. If you are using the old `Redmine\\Client` please [follow this migration guide](docs/migrate-to-psr18client.md).\n\nThe `Psr18Client` requires\n\n- a `Psr\\Http\\Client\\ClientInterface` implementation (like guzzlehttp/guzzle), [see](https://packagist.org/providers/psr/http-client-implementation)\n- a `Psr\\Http\\Message\\RequestFactoryInterface` implementation (like guzzlehttp/psr7), [see](https://packagist.org/providers/psr/http-factory-implementation)\n- a `Psr\\Http\\Message\\StreamFactoryInterface` implementation (like guzzlehttp/psr7), [see](https://packagist.org/providers/psr/http-message-implementation)\n- a URL to your Redmine instance\n- an Apikey or username\n- and optional a password if you want tu use username/password.\n\n\u003e :bulb: For security reason it is recommended that you use an ApiKey rather than your username/password.\n\n```diff\n\u003c?php\n\nrequire_once 'vendor/autoload.php';\n+\n+$guzzle = new \\GuzzleHttp\\Client();\n+$psr17Factory = new \\GuzzleHttp\\Psr7\\HttpFactory();\n+\n+// Instantiate with ApiKey\n+$client = new \\Redmine\\Client\\Psr18Client(\n+    $guzzle,\n+    $psr17Factory,\n+    $psr17Factory,\n+    'https://redmine.example.com',\n+    '1234567890abcdfgh'\n+);\n+// ...or Instantiate with Username/Password (not recommended)\n+$client = new \\Redmine\\Client\\Psr18Client(\n+    $guzzle,\n+    $psr17Factory,\n+    $psr17Factory,\n+    'https://redmine.example.com',\n+    'username',\n+    'password'\n+);\n```\n\n##### Guzzle configuration\n\nBecause the `Psr18Client` is agnostic about the HTTP client implementation every configuration specific to the transport has to be set to the `Psr\\Http\\Client\\ClientInterface` implementation.\n\nThis means that if you want to set any `cURL` settings to `Guzzle` you have multiple ways to set them:\n\n1. Using [Guzzle environment variables](https://docs.guzzlephp.org/en/stable/quickstart.html#environment-variables)\n2. Using [request options](https://docs.guzzlephp.org/en/stable/request-options.html) inside a `Psr\\Http\\Client\\ClientInterface` wrapper:\n\n```diff\n\u003c?php\n\nrequire_once 'vendor/autoload.php';\n\n+use Psr\\Http\\Client\\ClientInterface;\n+use Psr\\Http\\Message\\RequestInterface;\n+use Psr\\Http\\Message\\ResponseInterface;\n+\n$guzzle = \\GuzzleHttp\\Client();\n$psr17Factory = new \\Nyholm\\Psr7\\Factory\\Psr17Factory();\n\n+$guzzleWrapper = new class(\\GuzzleHttp\\Client $guzzle) implements ClientInterface\n+{\n+    private $guzzle;\n+\n+    public function __construct(\\GuzzleHttp\\Client $guzzle)\n+    {\n+        $this-\u003eguzzle = $guzzle;\n+    }\n+\n+    public function sendRequest(RequestInterface $request): ResponseInterface\n+    {\n+        return $this-\u003eguzzle-\u003esend($request, [\n+            // Set the options for every request here\n+            'auth' =\u003e ['username', 'password', 'digest'],\n+            'cert' =\u003e ['/path/server.pem', 'password'],\n+            'connect_timeout' =\u003e 3.14,\n+            // Set specific CURL options, see https://docs.guzzlephp.org/en/stable/faq.html#how-can-i-add-custom-curl-options\n+            'curl' =\u003e [\n+                CURLOPT_SSL_VERIFYPEER =\u003e 1,\n+                CURLOPT_SSL_VERIFYHOST =\u003e 2,\n+                CURLOPT_SSLVERSION =\u003e CURL_SSLVERSION_TLSv1_2,\n+            ],\n+        ]);\n+    }\n+};\n+\n// Instantiate with ApiKey\n$client = new \\Redmine\\Client\\Psr18Client(\n-    $guzzle,\n+    $guzzleWrapper,\n    $psr17Factory,\n    $psr17Factory,\n    'https://redmine.example.com',\n    '1234567890abcdfgh'\n);\n```\n\n## Built-in Redmine features\n\n### Impersonate User\n\nRedmine allows you [to impersonate another user](https://www.redmine.org/projects/redmine/wiki/Rest_api#User-Impersonation). This can be done using the methods `startImpersonateUser()` and `stopImpersonateUser()`.\n\n```php\n$client-\u003estartImpersonateUser('kim');\n// all requests will now impersonate the user `kim`\n\n// To stop impersonation\n$client-\u003estopImpersonateUser();\n```\n\n### API usage\n\nYou can now use the `getApi()` method to create and get a specific Redmine API.\n\n```php\n\u003c?php\n\n$client-\u003egetApi('user')-\u003elist();\n$client-\u003egetApi('user')-\u003elistLogins();\n\n$client-\u003egetApi('issue')-\u003ecreate([\n    'project_id'  =\u003e 'test',\n    'subject'     =\u003e 'some subject',\n    'description' =\u003e 'a long description blablabla',\n    'assigned_to_id' =\u003e 123, // or 'assigned_to' =\u003e 'user1' OR 'groupXX'\n]);\n$client-\u003egetApi('issue')-\u003elist([\n    'limit' =\u003e 1000\n]);\n```\n\n[See further examples and read more about usage in the docs](docs/usage.md).\n\n### Thanks!\n\n* Thanks to [Thomas Spycher](https://github.com/tspycher/) for the 1st version of the class.\n* Thanks to [Thibault Duplessis aka. ornicar](https://github.com/ornicar) for the php-github-api library, great source of inspiration!\n* And all the [contributors](https://github.com/kbsali/php-redmine-api/graphs/contributors)\n* specially [JanMalte](https://github.com/JanMalte) for his impressive contribution to the test coverage! :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbsali%2Fphp-redmine-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkbsali%2Fphp-redmine-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbsali%2Fphp-redmine-api/lists"}