Skip to content

Plugin Development: Getting Started

Ente edited this page Apr 6, 2025 · 1 revision

Plugin Development: Getting Started

To start developing your own plugins, first install a copy of timetrack. This will be your testing environment and already includes all resources to develop your own plugins.

Create Plugin

There are two ways to start this process, either by copying the template folder (located in api/v1/class/plugins) or by using the static function PluginBuilder::create_skeletton("your_plugin_name").

The function will simply do the same as copying, but already renames your plugin folder.

Change plugin.yml contents

The plugin.yml is the central interface for the PluginBuilder class to load your plugin as it communicates the base class and navigation links. It has the following structure:

  • name: Name of your plugin (and class) (e.g. yourPlugin)
  • src: The source folder of your plugin, containing the main class (default: src/)
  • main: The file name of your main class without file extension (default: Main)
  • namespace: Namespace of your plugin (e.g. yourPlugin)
  • author: Your name
  • description: A short description of your plugin
  • version: The version of your plugin
  • api: The API version used by the plugin (default: 0.1)
  • permissions: Currently not used, yet required (default: none).
  • enabled: Either true or false to enable or disable your plugin
  • custom.values: Like license information, up to you
  • nav_links: Mapping of [Name to Display]: [Relative file path], e.g. Manage something: views/manage.php
name: "MyPlugin"
src: "/src"
main: "Main"
namespace: "Example"
author: none
description: Plugin Skeletton
version: "1.0"
api: 0.1
permissions:
  none
enabled: true
custom.values:
 - testing 
nav_links:
  Test: "views/test.php"

You might then reflect these changes in the Main.php file within src/ directory

Change Main.php plugin class file

What you should change immediately (if changed in plugin.yml):

  • Namespace
  • Class Name
  • set_log_append() -> Name of your plugin / $log_append -> Name of your plugin
  • set_plugin_configuration() -> Name of your plugin
  • onLoad() -> Change logger message

You can then do any changes to your class, like adding new functions.

Using views

Views allow plugins to directly interact with users by providing a new page for the plugins menu. In your view, you should always make sure, that you do require the plugin & arbeitzeit loader, usually also your Main class file:

require_once $_SERVER["DOCUMENT_ROOT"] . "/api/v1/inc/arbeit.inc.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/api/v1/class/plugins/loader.plugins.arbeit.inc.php";
require_once dirname(__DIR__, 1) . "/src/Main.php";

use yourPlugin\yourPlugin;
$main = new yourPlugin;

$main->doSomething();

Clone this wiki locally