Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghostwriter/phtml
[WIP]A powerful PHP template engine designed to deliver high-performance, extensibility, and security.
https://github.com/ghostwriter/phtml
ghostwriter php phtml template-engine
Last synced: about 1 month ago
JSON representation
[WIP]A powerful PHP template engine designed to deliver high-performance, extensibility, and security.
- Host: GitHub
- URL: https://github.com/ghostwriter/phtml
- Owner: ghostwriter
- License: bsd-3-clause
- Created: 2024-07-24T00:41:42.000Z (4 months ago)
- Default Branch: 0.1.x
- Last Pushed: 2024-09-01T20:00:14.000Z (3 months ago)
- Last Synced: 2024-10-03T10:57:04.298Z (about 2 months ago)
- Topics: ghostwriter, php, phtml, template-engine
- Language: PHP
- Homepage: https://github.com/ghostwriter/phtml
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Phtml
[![Automation](https://github.com/ghostwriter/phtml/actions/workflows/automation.yml/badge.svg)](https://github.com/ghostwriter/phtml/actions/workflows/automation.yml)
[![Supported PHP Version](https://badgen.net/packagist/php/ghostwriter/phtml?color=8892bf)](https://www.php.net/supported-versions)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/ghostwriter?label=Sponsor+@ghostwriter/phtml&logo=GitHub+Sponsors)](https://github.com/sponsors/ghostwriter)
[![Code Coverage](https://codecov.io/gh/ghostwriter/phtml/branch/main/graph/badge.svg)](https://codecov.io/gh/ghostwriter/phtml)
[![Type Coverage](https://shepherd.dev/github/ghostwriter/phtml/coverage.svg)](https://shepherd.dev/github/ghostwriter/phtml)
[![Psalm Level](https://shepherd.dev/github/ghostwriter/phtml/level.svg)](https://psalm.dev/docs/running_psalm/error_levels)
[![Latest Version on Packagist](https://badgen.net/packagist/v/ghostwriter/phtml)](https://packagist.org/packages/ghostwriter/phtml)
[![Downloads](https://badgen.net/packagist/dt/ghostwriter/phtml?color=blue)](https://packagist.org/packages/ghostwriter/phtml)A powerful PHP template engine designed to deliver high-performance, extensibility, and security.
> [!WARNING]
>
> This project is not finished yet, work in progress.## Installation
You can install the package via composer:
``` bash
composer require ghostwriter/phtml
```### Star ⭐️ this repo if you find it useful
You can also star (🌟) this repo to find it easier later.
## Usage
```php
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:{{ $message }}
// "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; //
#BlackLivesMatter
```### Advanced Usage
```php
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']);
```### Credits
- [Nathanael Esayeas](https://github.com/ghostwriter)
- [All Contributors](https://github.com/ghostwriter/phtml/contributors)### Changelog
Please see [CHANGELOG.md](./CHANGELOG.md) for more information on what has changed recently.
### License
Please see [LICENSE](./LICENSE) for more information on the license that applies to this project.
### Security
Please see [SECURITY.md](./SECURITY.md) for more information on security disclosure process.