SavantPHP - The Simplest Templating System For PHP minimalist

SavantPHP is a simple and minimalistic, yet object-oriented, template system for PHP. It aims at ONE thing, being a simple & lightweight TEMPLATING system. We focus only on that ONE thing. PHP can do everything, so do everything with it, just use SavantPHP for only separating the "view/templating" concern from your business logic, that's it.

It has a proper namespace support and installable nicely via composer (unlike it's previous oldish one - see Credit section below)

Unlike other template systems, SavantPHP does not compile your templates into PHP; instead, it uses PHP itself as its template language so you don't need to learn a new markup system and you can use and access any method or functions within your app inside those template.

It is not a competitor to any of the likes of Dwoo or Twig..etc. SavantPHP is for those PHP/templating minimalists - "I just want to separate my front layer(view) from the back layer(code logic)" in the most simple and effective way and that's it, nothing more, nothing less, nothing else (no added crap).

How To Install SavantPHP

$ composer require sevenphp/savantphp

Why Use SavantPHP for Templates?


/* file.php */

use SavantPHP\SavantPHP;
$yourConfigBag = [
    \SavantPHP\SavantPHP::TPL_PATH_LIST => ['/path/to/yourViews/', '/path/to/someOtherFolder/anotherViewFolder/'], //as you can see, set all possible places where your template will reside
    \SavantPHP\SavantPHP::CONTAINER     => $yourContainer //can be anything, e.g a pimple container
$tpl = new SavantPHP($yourConfigBag);
$tpl->mynameis = 'Wasseem';

$tpl->display(); //or $response = $tpl->getOutput();
/* file.tpl.php | See how other **master templates** are also included within a template */

    <p>Hello, my name is <?php if(isset($this->mynameis)) echo $this->escape($this->mynameis) ?></p>

    <?php echo $this->includeTemplate('master/sidebar.tpl.php')?>

<?php echo $this->includeTemplate('master/footer.tpl.php')?>

Voila! Simple huh?





The Future

Your Contribution