bjornbasar / karhu-view
Template engine bridge for the karhu PHP microframework
dev-main
2026-04-14 06:55 UTC
Requires
- php: >=8.3
Suggests
- league/plates: For the Plates adapter
- twig/twig: For the Twig adapter
This package is auto-updated.
Last update: 2026-04-14 21:53:02 UTC
README
Template engine bridge for the karhu PHP microframework.
Provides a ViewInterface so controllers can render templates without coupling to a specific engine. Ships with Twig and Plates adapters.
Install
composer require bjornbasar/karhu-view # Then install your preferred engine: composer require twig/twig # for Twig # or composer require league/plates # for Plates
Usage
use Karhu\View\TwigAdapter; $view = new TwigAdapter(__DIR__ . '/templates'); $html = $view->render('home.html.twig', ['name' => 'karhu']); return (new Response())->withHeader('Content-Type', 'text/html')->withBody($html);
Custom engines
Implement ViewInterface:
use Karhu\View\ViewInterface; final class BladeAdapter implements ViewInterface { public function render(string $template, array $data = []): string { /* ... */ } }