makframework / template
PHP Engine Template
v0.1.0
2017-05-13 16:14 UTC
Requires
- twig/twig: ^2.0
This package is not auto-updated.
Last update: 2025-06-08 05:08:29 UTC
README
PHP Template Engine
It's a Template Engine developed with Twig as base.
Requeriments
- PHP Version 7.1 or higher
- Composer
Installation
$ composer require makframework/template
Usage
Create a index.php file with the following code:
<?php require 'vendor/autoload.php'; $tpl = new Template('./templates/'); $tpl->registerLanguages(['es' => './languages/es.ini']); $tpl->setData('user_id', 10); echo $tpl->render('home.html', ['title' => 'home', 'products' => ['PC','Mobile']]);
If you also want to translate any words, create a ".ini" file with the following code:
Some to translate = Algo para traducir
Create a ".html" file with the following code:
<html> <head> <title>{{title}}</title> </head> <body> <p>User ID: {{user_id}}</p> <ul> {% for product in products %} <li>{{producto}}</li> {% endfor %} </ul> <!-- translation --> <p>{{'Some to translate'|translate}}</p> </body> </html>
The output:
<html> <head> <title>home</title> </head> <body> <p>User ID: 10</p> <ul> <li>PC</li> <li>Mobile</li> </ul> <!-- translation --> <p>Algo para traducir</p> </body> </html>
Authors
License
Makframework\Template is licensed under the MIT license.
The project include others third-party libraries that can contain its own licenses: