Skip to content
Enable Blade for Kirby 3
Branch: master
Clone or download
Latest commit f5d70fd Feb 13, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Init commit Jan 23, 2019
LICENSE Init commit Jan 23, 2019
composer.json Fixed composer issue Feb 13, 2019
config.php Init commit Jan 23, 2019
index.php Fixed composer issue Feb 13, 2019

Kirby Blade

Kirby Blade use Laravel illuminate/view and jenssegers/blade packages.

This package enable Laravel Blade for your own Kirby applications.


Installation with composer

composer require beebmx/kirby-blade

What is Blade?

According to Laravel Blade documentation is:

Blade is the simple, yet powerful templating engine provided with Laravel. Unlike other popular PHP templating engines, Blade does not restrict you from using plain PHP code in your views. In fact, all Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application. Blade view files use the .blade.php file extension.


You can use the power of Blade like Layouts, Control Structures, Sub-Views, Directives and your Custom If Statements.

All the documentation about Laravel Blade is in the official documentation.


The default values of the package are:

Option Default Values Description
beebmx.kirby-blade.views site/cache/views (string) Location of the views cached
beebmx.kirby-blade.directives [] (array) Array with the custom directives
beebmx.kirby-blade.ifs [] (array) Array with the custom if statements

All the values can be updated in the config.php file.


All the views generated are stored in site/cache/views directory or wherever you define your cache directory, but you can change this easily:

'beebmx.kirby-blade.views' => '/site/storage/views',


By default Kirby Blade comes with 4 directives:


But you can create your own:

'beebmx.kirby-blade.directives' => [
    'greeting' => function ($text) {
        return "<?php echo 'Hello: ' . $text ?>";

If Statements

Like directives, you can create your own if statements:

'beebmx.kirby-blade.ifs' => [
    'logged' => function () {
        return !!kirby()->user();

After declaration you can use it like:

    Welcome back {{ $kirby->user()->name() }}
    Please Log In
You can’t perform that action at this time.