puff / view
Decoupled view rendering component for Puff Fiber Framework
Requires
- php: ^8.2
- puff/di: dev-main
Requires (Dev)
- eftec/bladeone: ^4.19
- latte/latte: ^3.0
- league/plates: ^3.0
- mustache/mustache: ^2.14
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.0
- twig/twig: ^3.0
Suggests
- eftec/bladeone: Enables the optional Blade renderer
- latte/latte: Enables the Latte renderer
- league/plates: Enables the Plates renderer
- mustache/mustache: Enables the Mustache renderer
- twig/twig: Enables the Twig renderer
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.