A powerful PHP template engine designed to deliver high-performance, extensibility, and security.
Warning
This project is not finished yet, work in progress.
You can install the package via composer:
composer require ghostwriter/phtml
You can also star (🌟) this repo to find it easier later.
use Ghostwriter\Phtml\Phtml;
$phtml = Phtml::new('path/to/templates', 'path/to/cache');
$phtml->registerNamespace('html', 'path/to/templates/html');
// File: path/to/templates/html/element/paragraph.phtml
// Content: <p>{{ $message }}</p>
// "html" is the namespace.
// "element" is the directory name inside the namespace.
// "paragraph" is the template filename inside the directory, without the ".phtml" extension.
$html = $phtml->render('html::element.paragraph',['message' => '#BlackLivesMatter']);
echo $html; // <p>#BlackLivesMatter</p>
use Ghostwriter\Phtml\Cache\PhtmlCache;
use Ghostwriter\Phtml\Compiler\PhtmlCompiler;
use Ghostwriter\Phtml\Engine\PhtmlEngine;
use Ghostwriter\Phtml\Loader\PhtmlLoader;
use Ghostwriter\Phtml\Renderer\PhtmlRenderer;
$cache = PhtmlCache::new('path/to/cache');
$loader = PhtmlLoader::new('path/to/templates');
$compiler = PhtmlCompiler::new($cache, $loader);
$engine = PhtmlEngine::new($compiler);
$renderer = PhtmlRenderer::new($engine);
$result = $renderer->render(template: 'alert', context: ['message' => '#BlackLivesMatter']);
Please see CHANGELOG.md for more information on what has changed recently.
Please see LICENSE for more information on the license that applies to this project.
Please see SECURITY.md for more information on security disclosure process.