leonickl / plate
There is no license information available for the latest version (v2.0.0) of this package.
A PHP templating engine
v2.0.0
2026-05-22 14:18 UTC
Requires
- php: >=8.4
This package is auto-updated.
Last update: 2026-05-22 14:24:44 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; }}
Import Components
{{ plug: 'nav' }}
{{ plug: 'person', data: $person }}
In order for this to work, you need to define this function and adjust it to your environment:
function plug_plate(string $file, mixed ...$params): string { return view($file, $params); // or however you import your views }
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