🚀 A new era: Kirby 4 Get to know
Skip to content

Improve IDE support

Many code editors and IDEs offer support for code completion suggestions or showing meta information about your variables, method calls etc. To make the most use of it, your IDE needs to know what types your variables hold.

Templates and snippets

Kirby exposes some general variables like $page, $site etc. to your templates as well as anything returned in the page controller. Your IDE however does not automatically know what these variables stand for. You can change this by adding comments specifying their types:

 * @var Kirby\Cms\App $kirby
 * @var Kirby\Cms\Site $site
 * @var Kirby\Cms\Page $page

  <?php foreach ($page->children() as $child): ?>
    <li><?= $child->title() ?></li>
  <?php endforeach ?>

Your IDE can now infer that $child is also a Kirby\Cms\Page object.


In your controllers, you can access the standard Kirby objects as arguments to your controller closure. By type-hinting them, your IDE can help you with completion suggestions etc.


use Kirby\Cms\App;
use Kirby\Cms\Page;
use Kirby\Cms\Pages;
use Kirby\Cms\Site;

return function (Site $site, Page $page, Pages $pages, App $kirby) {
    // ...

Page models

Make sure to do the same for your custom page models:


use Kirby\Cms\Page;

class NotePage extends Page
    // ...