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/phtmlYou can also star (🌟) this repo to find it easier later.
useGhostwriter\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>useGhostwriter\Phtml\Cache\PhtmlCache;
useGhostwriter\Phtml\Compiler\PhtmlCompiler;
useGhostwriter\Phtml\Engine\PhtmlEngine;
useGhostwriter\Phtml\Loader\PhtmlLoader;
useGhostwriter\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.