leonickl / plate
There is no license information available for the latest version (v1.0.3-BETA) of this package.
A PHP templating engine
v1.0.3-BETA
2026-05-02 11:20 UTC
Requires
- php: >=8.4
This package is auto-updated.
Last update: 2026-05-02 11:26:02 UTC
README
Plate
A lightweight PHP templating engine inspired by Laravel's Blade.
Features
- Simple, expressive syntax with
{{ }}delimiters - Automatic output escaping for security
- Conditional rendering with
if,elif, andelse - Loop support with
each - Raw PHP execution within templates
- Compiles to plain PHP for optimal performance
Requirements
- PHP >= 8.4
Installation
composer require leonickl/plate
Usage
<?php require 'vendor/autoload.php'; use LeoNickl\Plate\Plate; // Compile a .plate file to PHP code $phpCode = Plate::file('view.plate'); // Cast to string to get the compiled PHP echo (string) $phpCode;
Template Syntax
Printing Values
{{ "hello" }} // Escaped output
{{ ==$html }} // Unescaped output
{{ "hello", "world" }} // Multiple expressions (joined with space)
{{ :$var = "test" }} // Execute PHP without printing
Conditionals
{{ if: $condition }}
<p>Yes!</p>
{{ elif: $other }}
<p>Maybe!</p>
{{ else: }}
<p>No!</p>
{{ if; }}
Loops
{{ each: $items as $item }}
<p>{{ $item }}</p>
{{ each; }}
Example
See example.plate for a complete example. Run it with:
php index.php | php
This compiles the template and executes the resulting PHP.
Syntax Highlighting
Available for VSCode leonickl/plate-vscode