Quick Install

Step-by-step Tplix installation guide for Linux. Install the library, set up directories, configure your PHP entry point, and render your first template in under 10 minutes.

Quick Install

Get Tplix running in minutes. This guide is straight to the point — no fluff. It assumes you're comfortable with a Linux terminal. Windows users will need to adjust file permissions accordingly or use a hosting provider that supports them.

1

Install Library Files

Download and extract the Tplix library, then copy the files to a shared PHP library path. In this guide we use /usr/local/lib/php/Tplix/. If you're using FTP/SFTP, unzip locally and upload the extracted files to the same location.

command line
$> cd YOUR_DOWNLOAD_DIR $> tar -zxvf Tplix-3.0.tar.gz $> mkdir /usr/local/lib/php/Tplix $> cp -r Tplix-3.0/libs/* /usr/local/lib/php/Tplix

After copying, you should have the following file structure:

file structure
/usr/local/lib/php/Tplix/ debug.tpl plugins/ Tplix.class.php sysplugins/
2

Setup Directories

Tplix needs four directories: templates, templates_c (compiled), cache, and configs. It's recommended to place them outside your web server's document root for security. The web server PHP user needs write access to cache/ and templates_c/.

In this example the document root is /web/www.example.com/docs and the web server user is nobody. Tplix files will live under /web/www.example.com/tplix/. Permission 775 = user/group read+write, other read.
command line
$> cd /web/www.example.com $> mkdir tplix $> mkdir tplix/templates $> mkdir tplix/templates_c $> mkdir tplix/cache $> mkdir tplix/configs $> chown nobody:nobody tplix/templates_c $> chown nobody:nobody tplix/cache $> chmod 775 tplix/templates_c $> chmod 775 tplix/cache

Your directory layout should now look like this:

file structure
/web/www.example.com/ docs/ <-- web server document root tplix/ <-- outside document root (secure) templates/ <-- your .tpl template files templates_c/ <-- compiled templates (auto-generated, writable) cache/ <-- cached output (auto-generated, writable) configs/ <-- optional config files
3

Configure Your PHP Script

Create your application directory inside the document root and set up the entry point PHP file.

command line
$> cd /web/www.example.com/docs $> mkdir myapp $> cd myapp $> nano index.php

Edit index.php to look like the following:

index.php
<?php // full path to Tplix.class.php require('/usr/local/lib/php/Tplix/Tplix.class.php'); $tplix = new Tplix(); $tplix->setTemplateDir('/web/www.example.com/tplix/templates'); $tplix->setCompileDir('/web/www.example.com/tplix/templates_c'); $tplix->setCacheDir('/web/www.example.com/tplix/cache'); $tplix->setConfigDir('/web/www.example.com/tplix/configs'); $tplix->assign('name', 'Ned'); $tplix->display('index.tpl'); ?>
What each line does
require(...) Loads the Tplix library class from the path you installed it to
setTemplateDir Where Tplix looks for your .tpl template files
setCompileDir Where Tplix writes the compiled PHP versions of your templates (must be writable)
setCacheDir Where cached output is stored when caching is enabled (must be writable)
assign() Passes a PHP variable to the template — accessible as {$name}
display() Renders and outputs the named template file
4

Create Your First Template

Create the template file that index.php will render:

command line
$> nano /web/www.example.com/tplix/templates/index.tpl
index.tpl
<html> <head> <title>Tplix</title> </head> <body> Hello, {$name}! </body> </html>
Browser output
Hello, Ned!

Visit http://www.example.com/myapp/index.php — you should see this output. Tplix replaced {$name} with the value assigned in index.php.

Troubleshooting

If the page doesn't render correctly, run the built-in test utility. It verifies that all files and directories are in place and have the correct permissions:

PHP — add this temporarily to index.php
$tplix->testInstall();
Common issues
Blank page or PHP error
Double-check the path in require() — it must be the exact absolute path to Tplix.class.php
Permission denied error
The web server user (nobody, www-data, etc.) must have write access to cache/ and templates_c/
Template not found
Verify that index.tpl is in the exact directory set by setTemplateDir()
Up and running?

Explore the full documentation to learn about template syntax, caching, plugins, and template inheritance.

Full Documentation →