A PHP application to access your Kimai 2 installation via its API (http).
Requirements
- PHP 7.2.5
- cURL extension
- json extension
- iconv extension
- zlib extension
To install and update the Kimai console tools, execute the following commands:
curl -LO https://github.com/kevinpapst/kimai2-console/releases/latest/download/kimai.phar
chmod +x kimai.phar
mv kimai.phar /usr/local/bin/kimai
Before using it the first time, you have to create a configuration file, which holds the connection infos for Kimai.
By default this config file will be located at ~/.kimai2-console.json
:
kimai configuration:create
Make sure the file is only readable for your own user:
chmod 600 ~/.kimai2-console.json
That's it, you can use Kimai from the command line now.
By default the configuration file targets the demo installation and will work... but now its time to target your own Kimai, so edit the config file and change the settings: URL, username and API token.
You get a list of all available commands with kimai
.
kimai active
- display all running timesheetskimai stop
- stop currently active timesheetskimai start
- starts a new timesheetkimai customer:list
- show a list of customerskimai project:list
- show a list of projectskimai activity:list
- show a list of activitieskimai version
- show the full version string of the remote installationkimai configuration:create
- creates the initial configuration file
To get help for a dedicated command use the --help
switch, eg: kimai project:list --help
This command is rather clever and tries to detect customer, project and activity from your input in the following way:
- if it is a number, then it tries to load the entity by its ID
- if a entity is found, it will be used
- if it is a string, then this is just as search term
- if one entity is found, it will be used
- if multiple entities are found, a select list is shown
- if nothing is given or no reult was found in the previous steps, a list of all entities is fetched and shown for selection
- this list might be filtered (eg. only activities for found project)
Example to start a new timesheet by search terms only, adding some tags:
bin/kimai start --customer Schowalter --project analyzer --activity iterate --tags "test1, bla foo, kljhdflkjh kjh"
[OK] Started timesheet
* ID: 5070
* Begin: 2020-01-03T17:39:00+0100
* Project: Grass-roots system-worthy analyzer
* Activity: iterate viral infomediaries
This example would display a select list for all projects and then a select list for all activities for the chosen project:
bin/kimai start
This example would display a select list for all customers, then a filtered list for the projects of the chosen customer and finally a select list for all activities for the chosen project:
bin/kimai start --customer
The following environment variables are supported:
KIMAI_MEMORY_LIMIT
- configures the allowed memory limit (eg128MB
, or-1
for unlimited) (see here)KIMAI_CONFIG
- path to your configuration file (defaults to: $HOME/.kimai2-console.json)
- Bump version in
src/Constants.php
- Execute
box compile
- Prepare a new GitHub release
- Upload the file
kimai.phar
to the new release