{"id":17705146,"url":"https://github.com/jeromegamez/mite-php","last_synced_at":"2025-05-01T00:52:32.416Z","repository":{"id":52871291,"uuid":"167020384","full_name":"jeromegamez/mite-php","owner":"jeromegamez","description":"Interact with mite from your PHP application.","archived":false,"fork":false,"pushed_at":"2025-01-27T09:12:56.000Z","size":4373,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"3.x","last_synced_at":"2025-05-01T00:52:25.871Z","etag":null,"topics":["api","api-client","mite","mite-api","mite-sdk","php","time-tracking","timetracking"],"latest_commit_sha":null,"homepage":"https://mite.yo.lk","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeromegamez.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jeromegamez"}},"created_at":"2019-01-22T15:45:31.000Z","updated_at":"2025-01-27T09:12:52.000Z","dependencies_parsed_at":"2024-07-13T20:34:14.798Z","dependency_job_id":null,"html_url":"https://github.com/jeromegamez/mite-php","commit_stats":{"total_commits":55,"total_committers":3,"mean_commits":"18.333333333333332","dds":"0.036363636363636376","last_synced_commit":"5204ff01533b04ee5753417b559dd36b9850d9e9"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromegamez%2Fmite-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromegamez%2Fmite-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromegamez%2Fmite-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeromegamez%2Fmite-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeromegamez","download_url":"https://codeload.github.com/jeromegamez/mite-php/tar.gz/refs/heads/3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251806208,"owners_count":21646843,"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","api-client","mite","mite-api","mite-sdk","php","time-tracking","timetracking"],"created_at":"2024-10-24T22:06:43.608Z","updated_at":"2025-05-01T00:52:32.380Z","avatar_url":"https://github.com/jeromegamez.png","language":"PHP","readme":"# mite SDK for PHP\n\nInteract with [mite](https://mite.de) from your PHP application.\n\n[![Current version](https://img.shields.io/packagist/v/gamez/mite.svg?logo=composer)](https://packagist.org/packages/gamez/mite)\n[![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/gamez/mite)](https://packagist.org/packages/gamez/mite)\n[![Tests](https://github.com/jeromegamez/mite-php/actions/workflows/tests.yml/badge.svg)](https://github.com/jeromegamez/mite-php/actions/workflows/tests.yml)\n[![Sponsor](https://img.shields.io/static/v1?logo=GitHub\u0026label=Sponsor\u0026message=%E2%9D%A4\u0026color=ff69b4)](https://github.com/sponsors/jeromegamez)\n\n---\n\n* [Requirements](#requirements)\n* [Installation](#installation)\n* [Usage](#usage)\n  * [Basic API client](#basic-api-client)\n  * [Simple API](#simple-api)\n  * [Simple Tracker](#simple-tracker)\n  * [Catching errors](#catching-errors)\n  * [Caching HTTP requests](#caching-http-requests)\n  * [Creating your own API client](#creating-your-own-api-client)\n* [License](#license)\n\n---\n\n## Requirements\n\n- An account name (The first part of your mite account's domain, e.g. in https://**xxx**.mite.de)\n- An API key (You can find your API key on https://xxx.mite.de/myself)\n\nPlease note that the capabilities of the library are limited by the permissions of the used credentials.\nAs an example, a user with the role \"Time Tracker\" can only access data that has been made available \nto them and is not allowed to create new customers.\n \nUsers with the `admin` role can see and do (almost) everything.\n\n---\n\n## Installation\n\nIn order to use this library, you need a [PSR-18 HTTP Client](https://packagist.org/providers/psr/http-client-implementation), and a\n[PSR-17 HTTP Message Factory](https://packagist.org/providers/psr/http-factory-implementation). If you don't already have them available in your project,\nthey will be added to your project's dependencies\n\n```bash\ncomposer require gamez/mite\n```\n\n## Usage\n\n### Basic API client\n\nOnce you have created an HTTP Client and Request Factory as described in the installation section,\nyou can create an API client with them:\n\n```php\n\u003c?php\n\nuse Gamez\\Mite\\Api\\HttpApiClientFactory;\n\n$apiClientFactory = new HttpApiClientFactory();\n\n$apiClient = $apiClientFactory('my_account', 'api_key');\n```\n\nThis API client allows you to make authenticated HTTP requests to the API of your mite account - \nsee [mite's REST API documentation](https://mite.de/en/api/) for the endpoints you can use.\n\n### Simple API\n\n[`Gamez\\Mite\\SimpleApi`](./src/SimpleApi.php) is the easiest and fastest way to access the data in your \nmite account. Its methods are named after the [available REST API endpoints](https://mite.de/en/api/) \nand always return arrays of data. You can inspect the available methods by looking at the\n[source code of the `Gamez\\Mite\\SimpleApi` class](./src/SimpleApi.php) or by using the \nautocompletion features of your IDE.\n\nThe Simple API doesn't get in your way when accessing the mite API, but it doesn't provide additional \nfeatures either. It will, for example, not tell you if you used a wrong query parameter or invalid\nfield value, so you will have to rely on the returned API responses.\n\nFor information on which query parameters and field values are allowed, see \n[official mite API documentation](https://mite.de/en/api/)\n\n#### Example\n\n```php\nuse Gamez\\Mite\\SimpleApi;\n\n/** \n * @var \\Gamez\\Mite\\Api\\ApiClient $apiClient \n */\n$api = SimpleApi::withApiClient($apiClient);\n\n$customer = $api-\u003ecreateCustomer([\n    'name' =\u003e 'My new customer',\n    'note' =\u003e 'He pays better than the old one',\n]);\n\necho 'Customer: '.print_r($customer, true);\n\n$project = $api-\u003ecreateProject([\n    'name' =\u003e 'My new customer project',\n    'customer_id' =\u003e $customer['id'],\n    'budget_type' =\u003e 'minutes_per_month',\n    'budget' =\u003e 6000,\n    'hourly_rate' =\u003e 10000,\n    'active_hourly_rate' =\u003e 'hourly_rate',\n]);\n\necho 'Project: '.print_r($project, true);\n\n$service = $api-\u003ecreateService([\n    'name' =\u003e 'Customer Support',\n]);\n\necho 'Service: '.print_r($service, true);\n\n$user = current($api-\u003egetActiveUsers()); // For the sake of this example, we use the first available user\n\necho 'User: '.print_r($user, true);\n\n$timeEntry = $api-\u003ecreateTimeEntry([\n    'date_at' =\u003e 'today',\n    'minutes' =\u003e 60,\n    'user_id' =\u003e $user['id'], // Would we omit this, the authenticated user would be used\n    'project_id' =\u003e $project['id'],\n    'service_id' =\u003e $service['id'],\n    'note' =\u003e 'We had some work to do, and we did some work.'\n]);\n\necho 'Time Entry: '.print_r($timeEntry, true);\n\n// $api-\u003edelete($newTimeEntry['id'];\n\n$workdaysPerMonthAndUser = $api-\u003egetGroupedTimeEntries($groupBy = ['user'], ['at' =\u003e 'this_month']);\n\necho 'Workdays per month and user: '.print_r($workdaysPerMonthAndUser, true);\n```\n\n### Simple Tracker\n\n[`Gamez\\Mite\\SimpleTracker`](./src/SimpleTracker.php) allows you to work with mite's time tracker.\n\n**Note:** You can only access the tracker of the currently authenticated user (identified by the used API key).\nIt is not possible to modify trackers of other users. \n\nEach action on the tracker returns an array with information about the tracked time entry, but you don't have\nto inspect the result to know if the action has been successful or not - if an action does not throw an \nerror, it has been successful.\n\n```php\nuse Gamez\\Mite\\SimpleApi;\nuse Gamez\\Mite\\SimpleTracker;\n\n/** @var \\Gamez\\Mite\\Api\\ApiClient $apiClient */\n$api = SimpleApi::withApiClient($apiClient);\n$tracker = SimpleTracker::withApiClient($apiClient);\n\n$sleeping = $api-\u003ecreateTimeEntry(['note' =\u003e 'I am sleeping']);\n$working = $api-\u003ecreateTimeEntry(['note' =\u003e 'I switch to this now and then']);\n\n$tracker-\u003estart($sleeping['id']);\nsleep(1); // You don't need this sleep, but the example makes more sense this way\n$tracker-\u003estart($working['id']); // This will automatically stop the \"sleeping\" tracker\n// No sleep this time, we'll just work for zero seconds \n$tracker-\u003estop($working['id']); // We stopped working!\n\nprint_r($tracker-\u003estatus()); // Sad\n```\n\n### Catching errors\n\nAll exceptions thrown by this library implement the `\\Gamez\\Mite\\Exception\\MiteException` interface.\nExceptions thrown while using an API Client will throw a `\\Gamez\\Mite\\Exception\\ApiClientError`.\n\n```php\nuse Gamez\\Mite\\Exception\\ApiClientError;\nuse Gamez\\Mite\\Exception\\MiteException;\n\ntry {\n    /** @var \\Gamez\\Mite\\Api\\ApiClient $apiClient */\n    $result = $apiClient-\u003eget('nice-try');\n} catch (ApiClientError $e) {\n    $message = \"Something went wrong while accessing {$e-\u003egetRequest()-\u003egetUri()}\";\n\n    if ($response = $e-\u003egetResponse()) {\n        $message .= \" ({$response-\u003egetStatusCode()})\";\n    }\n\n    $message .= ' : '.$e-\u003egetMessage();\n\n    exit($message);\n} catch (MiteException $e) {\n    exit('Something not API related went really wrong: '.$e-\u003egetMessage());\n}\n\n// Something went wrong while accessing https://xxx.mite.de/nice-try (404) :\n// The URI /nice-try could not be found.\n```\n\n### Caching HTTP requests\n\nTo cache HTTP requests to the API, you can add a caching middleware/plugin to the HTTP client\nbefore injecting it into the API client instance. See the documentation of the respective\ncomponent for instructions on how to do that.\n\n* Guzzle: [kevinrob/guzzle-cache-middleware](https://github.com/Kevinrob/guzzle-cache-middleware)\n* HTTPlug: [Cache Plugin](http://docs.php-http.org/en/latest/plugins/cache.html)\n\n### Creating your own API client\n\nIf you want to create your own API client, implement the `\\Gamez\\Mite\\Api\\ApiClient` interface\nand use your implementation.\n\n## License\n\n`gamez/mite` is licensed under the [MIT License](LICENSE).\n\nYour use of mite is governed by the [Terms of Service for mite.](https://mite.de/en/terms.html).\n","funding_links":["https://github.com/sponsors/jeromegamez"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeromegamez%2Fmite-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeromegamez%2Fmite-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeromegamez%2Fmite-php/lists"}