bjornbasar/karhu-view

Template engine bridge for the karhu PHP microframework

Maintainers

Package info

github.com/bjornbasar/karhu-view

pkg:composer/bjornbasar/karhu-view

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-04-14 06:55 UTC

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 { /* ... */ }
}