Search by

crystoline / xpsr-view-plates

crystoline

Plates views for XPSR applications: native PHP templates in place of Twig

Package info

github.com/crystoline/xpsr-view-plates

Homepage

pkg:composer/crystoline/xpsr-view-plates

Statistics

Installs: 3

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v0.5.0 2026-10-30 11:06 UTC

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+.