puff/view

Decoupled view rendering component for Puff Fiber Framework

Maintainers

Package info

github.com/php-puff/view

pkg:composer/puff/view

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-08-28 07:49 UTC

This package is auto-updated.

Last update: 2026-08-28 07:51:05 UTC


README

puff/view is the standalone view rendering component for PHP Fiber Framework. It includes a dependency-free native PHP renderer and optional adapters for Twig, Latte, Plates, Mustache, and Blade.

Installation

composer require puff/view

The native PHP renderer requires no template-engine dependency. Install only the adapter used by the application:

composer require twig/twig
composer require latte/latte
composer require league/plates
composer require mustache/mustache
composer require eftec/bladeone

Standalone usage

use Puff\View\Renderer\PhpRenderer;
use Puff\View\View;

$view = new View(new PhpRenderer(
    paths: [__DIR__ . '/resources/views'],
    cacheDirectory: __DIR__ . '/runtime/views',
));

echo $view->render('home.php', ['title' => 'Puff']);

Puff configuration

The package is discovered through Composer and registers both Puff\View\View and the view container alias automatically. On installation, config/view.php is published when the application does not already provide that file.

return [
    'view' => [
        'driver' => 'php',
        'paths' => [dirname(__DIR__) . '/resources/views'],
        'cache' => dirname(__DIR__) . '/runtime/views',
        'options' => [],
    ],
];
$html = app('view')->render('home.php', ['title' => 'Puff']);

The helper and Fiber-aware facade are also available:

use Puff\View\Facades\View;

$html = view('home.php', ['title' => 'Puff']);
$html = View::render('home.php', ['title' => 'Puff']);

Supported drivers are php, twig, latte, plates, mustache, and blade. Template-engine packages are optional and are never loaded by the native renderer.

BladeOne

The blade driver uses BladeOne instead of Illuminate View, keeping the adapter small and independent from Laravel's container, events, filesystem, and support packages.

return [
    'view' => [
        'driver' => 'blade',
        'paths' => [dirname(__DIR__) . '/resources/views'],
        'cache' => dirname(__DIR__) . '/runtime/views',
        'options' => [
            'mode' => 'auto', // auto, slow, fast, or debug
            'comment_mode' => 0,
        ],
    ],
];

Common Blade syntax such as escaped/raw output, conditions, loops, layouts, sections, includes, stacks, and custom directives is supported. BladeOne is not a complete Laravel runtime: dynamic Blade components, <x-*> templates, Laravel extensions, and Laravel service injection are not compatibility targets.

View data must be passed explicitly for every render:

echo view('home', ['title' => 'Puff']);

Renderers do not retain assigned request data. The discovered View service is Fiber-scoped to prevent mutable engine state from leaking between concurrent requests.