leitsch/kirby-blade
Adds Laravel Blade templating to Kirby: render .blade.php templates with Blade directives, components, and layouts while keeping Kirby's data, plugins, and site structure. A lightweight bridge between Kirby and Laravel's view layer for cleaner, more expressive templates.
composer require leitsch/kirby-blade. If your Kirby project doesn't use Composer for plugins, clone the repo into site/plugins/kirby-blade and run composer install inside it.$kirby->plugins() for leitsch/kirby-blade. Kirby 4/5 auto-discovers plugins in site/plugins; Composer setups need the standard Kirby plugin wiring.index.php and src/ to see how the Blade compiler and view finder are wired. That tells you the view search paths and the template suffix the package expects (typically .blade.php — verify the exact convention before mass-renaming).site/templates/home.blade.php alongside the existing home.php and render {{ $page->title() }}. Blade and PHP templates coexist, so migration can be incremental.@extends/@section/@yield for site chrome. Keep layouts in a subfolder the view finder can reach (e.g. site/templates/layouts/) and confirm the dotted name resolves.@include('partials.nav', ['items' => $site->children()]). Prefer Blade includes over Kirby snippets for markup you render from templates; keep PHP snippets only for shared logic.$page, $site, $kirby, $pages, $files, $user, $request. Treat them as already-passed view data; don't re-fetch what's in scope.site/controllers/<template>.php returning an array is the closest analogue to a Laravel controller returning view data. Use it to keep logic out of Blade, then read the keys as normal variables in the template.{{ }} escapes HTML. Kirby richtext and HTML fields need {!! $page->text()->kirbytext() !!} (or ->html()).Blade::directive('kirbytext', fn ($expr) => "<?php echo kirbytext($expr); ?>"), then use @kirbytext($page->text()) everywhere.@component/@slot work well for cards, nav items, and other UI fragments repeated across templates..php original until the Blade version is verified, then delete. This keeps the site shippable throughout.site/cache/ or defined by the package) and know how to clear it — stale compiled templates are the usual cause of "my change isn't showing." Clear after every deploy and after editing directives.@if, @foreach, @include, @extends work; @csrf, @auth, route(), config(), and package-specific directives do not. Don't paste Laravel views assuming they'll run.Blade::directive(...) in the plugin's boot/config path before views render. Registering late leaves the old compiled output in place until you clear the cache.$page, $site, or a controller rather than guessing at a Laravel-style global.'debug' => true in site/config/config.php, and when a directive misbehaves, open the compiled Blade file to see the generated PHP. Errors inside directives surface as opaque PHP errors, so the compiled output is usually faster to read than the stack trace.composer.json, test Kirby upgrades in a branch, and watch the repo for breaking changes rather than assuming it tracks every Kirby minor.src/) are the natural hooks. Never edit vendor/ — subclass or wrap in a project plugin so upgrades stay clean.How can I help you explore Laravel packages today?