What is TPLix
Learn what TPLix is — a PHP template engine that separates presentation from application logic using simple {tag} syntax. Fast, secure, and free to use.
TPLix is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. PHP code is application logic — TPLix handles the presentation.
The Philosophy
The TPLix design was largely driven by these goals:
Templates: Two Camps of Thought
Mixes PHP code directly with HTML. Fast in theory, but messy and hard to maintain. PHP works well for logic — not so well for markup.
Presentation is void of programming code. Simple {tags} indicate where content appears. Clean, focused, maintainable.
Why is Separating PHP from Templates Important?
Syntax
TPLix's simple {tag} syntax is designed specifically for presentation — intuitive for developers and designers alike.
<?php echo strtolower(
htmlspecialchars(
$title,ENT_QUOTES,'UTF-8'
)
); ?>
{$title|escape|lower}
Sandboxing
TPLix insulates templates from PHP, creating a controlled separation of presentation from business logic. Security features can enforce granular restrictions — ideal when third parties edit templates.
Portability
TPLix templates are language-agnostic — they can be compiled to other languages such as JavaScript with a different compiler, and the syntax can be ported to other programming languages.
How Does it Work?
Under the hood, TPLix compiles template files into PHP scripts. Compilation happens once on first invocation — compiled versions are reused from that point forward. Since compiled output is pure PHP, op-code accelerators like APC or ZendCache continue to work.
Template Inheritance
Before template inheritance, templates were managed in separate header/footer files — fragile and hard to maintain. With template inheritance, templates are maintained as single pages and blocks of content are manipulated by inheriting them. See Template Inheritance for more info.
What TPLix is Not
⚠️ TPLix is not an application framework, not an MVC, and not a replacement for CodeIgniter, CakePHP, or Zend Framework. TPLix is the (V)iew layer — it works alongside any framework.
Is TPLix Right for Me?
Are you content with PHP mixed with HTML? Would your designers prefer a clean tag-based syntax designed purely for presentation?
Do you need to insulate templates from PHP? Do untrusted third parties edit your templates? Do you need fine-grained control over what is available in templates?
Does TPLix's caching, template inheritance, and plugin architecture save development time compared to building these features from scratch?
Sites Using TPLix
Tens of thousands of developers visit the TPLix website daily. Well-known PHP projects using TPLix include:
Summary
Whether you are using TPLix for a small website or a massive enterprise solution, it can accommodate your needs: