Kirby3 Janitor - a panel button to run jobs defined in php

I am creating posts for my plugins to make it easier to find them using the forum search and not just the docs search.

Kirby 3 Plugin for running jobs.

  • It is a Panel Button!
  • It has jobs build-in for cleaning the cache, sessions, create zip-backup, pre-generate thumbs, open URLs, refresh the current Panel page, download a file, copy to clipboard and more.
  • You can define your own jobs (call API hooks, play a game, hack a server, …)
  • It can be triggered in your frontend code and with CRON.
  • It can also be used as a CLI with fancy output.
  • It can also create logs of what it did.

register and define a job as callback aka closure

site/config/config.php

'bnomei.janitor.jobs' => [
    'aweSomeItCouldBe' => function (Kirby\Cms\Page $page = null, string $data = null) {
        // $page => page object where the button as pressed
        // $data => 'my custom data'
        return [
            'status' => 200,
            'label' => $page->title() . ' ' . $data,
        ];
    },
    'query' => function (Kirby\Cms\Page $page = null, string $data = null) {
        return [
            'status' => 200,
            'label' => $data, // this is the current panel users email
        ];
    },
]

add a panel button

site/blueprints/pages/default.yml

  janitor:
    type: janitor
    label: Awesome
    progress: Awesome...
    job: aweSomeItCouldBe

  janitor_query:
    type: janitor
    label: Query '{{ user.email }}'
    job: query
    data: '{{ user.email }}'

with new v2.13.0 you can now use janitor in CLI mode to

  • janitor --tinker will start a very simple REPL session.
  • janitor --down will put your frontend in maintenance mode. Panel will still be usable.
  • janitor --up will stop the maintenance mode.