PHP code example of setono / php-templates

1. Go to this page and download the library: Download setono/php-templates library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

setono / php-templates example snippets



// render.php

use Setono\PhpTemplates\Engine\Engine;

$engine = new Engine();
$engine->addPath('templates/php');

echo $engine->render('@App/hello', [
    'name' => 'John Doe',
]);


// override.php

use Setono\PhpTemplates\Engine\Engine;

$engine = new Engine();
$engine->addPath('vendor/namespace/src/templates/php'); // The path is added with a default priority of 0
$engine->addPath('templates/php', 10); // Here we set the priority higher than the vendor added path


echo $engine->render('@ThirdPartyNamespace/hello', [
    'name' => 'John Doe',
]);
html
<h1>Hello <?=$name
bash
$ composer 
html
<!-- templates/php/App/hello.php -->
<h1>Hello <?=$name
html
<!-- vendor/namespace/src/templates/php/ThirdPartyNamespace/hello.php -->
<h1>Hi <?=$name
html
<!-- templates/php/ThirdPartyNamespace/hello.php -->
<h1>Hi <?=$name