It's better when it's simple

User Tools

Site Tools


CLI Plugins

CLI (Command Line Interface) plugins give you an easy way to provide more DokuWiki features accessible from the command line. This is mostly useful as component in a larger plugin where certain functionality should be run from Cron jobs or by experienced Administrators only.

CLI plugins are based on the php-cli library, it's documentation might be an additional help.

Available CLI Plugins are listed. They can be installed via the Extension Manager.

Executing CLI Plugins

DokuWiki comes with bin/plugin.php. Call it without parameters to list all available CLI plugins. Call it with the name of the plugin as the first argument to call that plugin.

For the Example plugin below, call

./bin/plugin.php example -v


An CLI Plugin Example needs:

  • class name cli_plugin_example
  • which extends DokuWiki_CLI_Plugin1).
  • to be stored in a file lib/plugins/example/cli.php.

For full details of plugins and their files and how to create more CLI components refer to plugin file structure.

Required Implementation

Inheriting from the DokuWiki_CLI_Plugin requires you to implement multiple methods in your class.


This method is passed an Option object on which you should call multiple methods to configure the behavior of your CLI tool. This configures which arguments and parameters are accepted and required for your tool.

Refer to the Options documentation on the available methods.


This method is passed an Option object from which you can get all the parsed arguments and parameters.

This is where you should call your main code. You might want to use a Helper Plugin here.


if(!defined('DOKU_INC')) die();
use splitbrain\phpcli\Options;
class cli_plugin_example extends DokuWiki_CLI_Plugin {
    // register options and arguments
    protected function setup(Options $options) {
        $options->setHelp('A very minimal example that does nothing but print the plugin version info');
        $options->registerOption('version', 'print version', 'v');
    // implement your code
    protected function main(Options $options)
        if ($options->getOpt('version')) {
            $info = $this->getInfo(); // method available in all DokuWiki plugins
        } else {
            echo $options->help();
defined in lib/plugins/cli.php
devel/cli_plugins.txt · Last modified: 2021-08-24 00:18 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki