crystoline / xpsr-view-plates
Plates views for XPSR applications: native PHP templates in place of Twig
Requires
- php: ^8.4
- crystoline/xpsr-framework: ^0.5@dev
- league/plates: ^3.6
Requires (Dev)
- nyholm/psr7: ^1.8.2
- phpunit/phpunit: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-30 11:16:39 UTC
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+.