Skip to content

Kirby 6.0.0

query

Options for the Kirby query language

Runner

Kirby parses each query as an abstract syntax tree and resolves it with the Kirby\Query\Runners\DefaultRunner class. The query.runner option lets you replace it with your own runner class:

site/config/config.php
return [
  'query' => [
    'runner' => MyQueryRunner::class
  ]
];

Custom query runner

A custom runner extends the abstract Kirby\Query\Runners\Runner class and implements two methods: the static ::for() method creates the runner for a Kirby\Query\Query object, and ::run() resolves a query string with the given context data.

To keep Kirby's parser, extend Kirby\Query\Runners\DefaultRunner instead and override its ::run() method to resolve the parsed syntax tree with your own visitor. Visitors extend the abstract Kirby\Query\Visitors\Visitor class. Kirby's Kirby\Query\Visitors\DefaultVisitor is a good starting point, as it already resolves every node of the tree.