This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Extremely lightweight template class based on native PHP. Forked from:

dev-master 2015-03-15 05:59 UTC

This package is not auto-updated.

Last update: 2021-10-16 00:32:01 UTC



This package is a part of the Hups Framework. It is an extremely lightweight template class based on native PHP.

This library is forked from:



Add shakahl/hups-util-phptemplate as a requirement to composer.json:

    "require": {
        "shakahl/hups-util-phptemplate": "dev-master"

Update your packages with composer update or install with composer install.

You can also add the package using composer require shakahl/hups-util-phptemplate and later specifying the version you want (for now, dev-master is your best bet).  

Usage example


Example for usage

$path = './templates/';  

$tpl = new \Hups\Util\PHPTemplate('/path/to/template_file.php');
$tpl->some_title = 'User list';
$tpl->userArray = array(
        "id" =>  1,
        "name" => "John Doe1"
        "id" =>  2,
        "name" => "John Doe2"
        "id" =>  3,
        "name" => "John Doe3"
$tpl->set('another_variable', 'some value');
$tpl->assign('another_variable2', 'some value');
$renderedOutput = $tpl->fetch('template-tpl.php');


Example template file

<!-- test_template.tpl.php -->
<h1><?php echo $some_title; ?></h1>
    <?php foreach($userArray as $usr): ?>  
        <td><?php echo $usr['id']; ?></td>  
        <td><?php echo $usr['name']; ?></td>  
    <?php endforeach; ?>  
<?php echo $this->another_variable; // Can be used like this ?>


Unit testing


Under Windows

$ composer update
$ vendor/bin/phpunit​.bat


Under Linux

$ composer update
$ vendor/bin/phpunit​