crystoline / xpsr-view-plates
Plates views for XPSR applications: native PHP templates in place of Twig
v0.8.0
2026-11-04 16:07 UTC
Requires
- php: ^8.4
- crystoline/xpsr-framework: ^0.8@dev
- league/plates: ^3.6
Requires (Dev)
- nyholm/psr7: ^1.8.2
- phpunit/phpunit: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Plates views for XPSR applications: native PHP templates in place of Twig.
composer require crystoline/xpsr-view-plates
// config/app.php 'view_engine' => env('VIEW_ENGINE', 'plates'),
views/home/index.php is the view home.index:
<?php $this->layout('layouts/main', ['title' => 'Tasks']) ?> <h1>Hello, <?= $this->e($user->name) ?></h1> <?php if ($this->can('update', $task)): ?> <form method="post" action="/tasks/<?= $this->e($task->id) ?>"> <?= $this->csrf_field() ?> <input name="title"> </form> <?php endif ?>
Plates prints whatever a template echoes, so escape every value with $this->e(). The template functions are methods of $this; csrf_field() returns HTML to print as it is. Layouts, sections, and insert() work as in the Plates documentation.
PlatesViewHandler::engine() returns the Plates Engine, for folders, shared data, and extensions. Templates are PHP, so OPcache caches them and app.view_cache_dir is not used.
Requires PHP 8.4+.