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.
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.
After copying, you should have the following file structure:
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/.
/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.
Your directory layout should now look like this:
Configure Your PHP Script
Create your application directory inside the document root and set up the entry point PHP file.
Edit index.php to look like the following:
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
Create Your First Template
Create the template file that index.php will render:
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:
require() — it must be the exact absolute path to Tplix.class.phpnobody, www-data, etc.) must have write access to cache/ and templates_c/index.tpl is in the exact directory set by setTemplateDir()Explore the full documentation to learn about template syntax, caching, plugins, and template inheritance.