Trongate PHP Framework Docs
Introduction
Basic Concepts
Understanding Routing
Intercepting Requests
Module Fundamentals
Database Operations
Templates
Helpers
Form Handling
Form Validation
Working With Files
Image Manipulation
Working With Dates & Times
Language Control
Authorization & Authentication
Tips And Best Practices

The Big Picture

You already know that view files are just PHP files. HTML + <?= $var ?> = done. No template engine. No drama.

Now meet the next level: templates.

Templates

Templates are full-page PHP files that define the complete HTML skeleton – <!DOCTYPE html> to </html>. Header, footer, navigation, global scripts – the stuff that’s identical on every page.

One line loads everything and injects your view. For example:

The $data array is automatically available in both the template and the view. Zero extra code.

Templates vs Views (definitions)

  • Templates – the wrapper (full HTML page)
  • Views – the changing content inside it

Templates load views. Views never load templates. Clean separation. Done.

Where Templates Live

Everything lives in the templates module – just like any other module:

In Trongate v1, templates was a folder that existed at the root directory level. Trongate v1 also contained a 'Template' class (within the engine directory) and a few features that nobody needs, such as themes and partials.

Trongate v2 changes the game. Now, templates is an ordinary module that exists within the modules directory. All of the code pertaining to templates that was previously in the engine directory has been removed. In short, everything to do with templates has been simplified.

Why This Wins

  • 100% Native PHP – no new syntax
  • No extra folders or config files
  • Fully portable – templates can be dropped into any project
  • Works exactly like every other module
  • Switch layouts with one line, no registration required
  • In Trongate v2, "Templates" is just an ordinary module.
  • View files get injected inside templates.
  • The Trongate framework does not contain a templating engine and, instead, favors Native PHP.