Skip to content

Kirby 3.9.8

Roots

The $roots object gives you access to the roots of the different folders that make up your Kirby installation. This is useful whenever you want to access those folders to fetch a file from a folder etc.

Accessing the $roots object

Before you can call the method, you need access to the roots object:

$roots = $kirby->roots();

This will return an object with all the roots of the installation.

With the object in place, you can now call the available roots methods.

Instead of the following syntax to access the folders:

$accounts = $kirby->roots()->accounts();

you can also use the root() method to access an individual root directly:

$accounts = $kirby->root('accounts');