Kirby's PHP API
Kirby has a mighty PHP API, which you can use in your snippets, templates, controllers and plugins to access each and every bit and piece of data and aspect of your site and system.
Key objects
Object available | Description |
---|---|
$kirby › |
The $kirby class is the heart and soul of Kirby. It's the access point for registered users, the current request, route, plugins and more. |
$site › |
The $site object represents the root of your site with all the information stored in /content/site.txt . |
$pages › |
The $pages object contains the first level of pages. It can be used to build the main menu or dive deeper into the structure of your site. |
$page › |
The $page object represents the currently active page. It gives you access to the page's data, attached files, subpages and more. |
All the classes
There are a lot more classes and objects at play within Kirby. You can find the most common ones in the Reference:
Permissions
Some parts of Kirby's PHP API only work if you are logged in (or authenticated in other ways), because they respect the permissions of the currently logged in user. E.g. users cannot update a page via $page->update()
, unless they are logged in and have adequate permissions. This helps increase the security of your code by blocking operations for unauthorized users.
You can read more about available user permissions as well as how to authenticate or impersonate in the Users permissions docs ›