litphp / view-plates
Plates integration for lit
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/litphp/view-plates
Requires
- league/plates: ^3.3.0
- litphp/air: ^0.9
- litphp/voltage: ^0.9
Requires (Dev)
- phpstan/phpstan-phpunit: ^0.11.2
- phpstan/phpstan-shim: ^0.11.7
- phpunit/phpunit: ^7.5
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2025-09-29 02:07:59 UTC
README
Plates integration for lit
Usage
In a standard litphp/project:
- add dependency & install
composer require litphp/view-plates
- append configuration
Create a template dir in your project root, says template
. Write your first template file templates/index.php
Hello <?=$this->e($name)?>!
Merge PlatesView::configuration
into your configuration.php
.
$configuration += \Lit\View\Plates\PlatesView::configuration([ __DIR__ . '/templates', ]);
- integration in action class
In src/BaseAction.php
, use the trait PlatesViewBuilderTrait
abstract class BaseAction extends BoltAbstractAction { use \Lit\View\Plates\PlatesViewBuilderTrait;
Change your src/HomeAction.php
to render page use plates
class HomeAction extends BaseAction { protected function main(): ResponseInterface { return $this->plates('index')->render(['name' => '<plates>']); }
That's all! Run your app by php -S 127.0.0.1:3080 public/index.php
, and open http://127.0.0.1:3080/. You should see greetings from plates template Hello <plates>!
(notice <>
should be escaped correctly)