Trongate PHP Framework Docs
Introduction
Quick Start
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
Security
Tips And Best Practices

Everything Is A Module

In Trongate v2, everything is a module. Every piece of built-in functionality - database handling, form rendering, file uploads, image manipulation, template rendering, validation, even helper functions - lives inside a dedicated module.

This isn't just philosophy. It's the architecture of the framework.

What Is a Module?

A module is a folder. That's it.

Each module lives inside modules/ and contains a controller file with the same name as the folder. Some modules add a model file (Some_module_model.php) and a views/ directory. But the bare minimum is a folder and a controller.

Here's the db module - the one that powers all database interactions:

That's it. One folder. One file. Yet it handles every query, every transaction, every table operation you'll ever need.

What "Everything" Actually Means

Open the modules/ directory in any Trongate v2 installation and you'll see:

Module What It Does
dbDatabase connections, queries, CRUD operations
fileFile upload, move, copy, delete, directory management
flashdataOne-time session messages
formAll form helper functions
imageImage resize, crop, rotate, upload configuration
languageMultilingual support, language file loading
paginationPage navigation for result sets
string_serviceString manipulation helpers (truncate, split, filter)
templatesAdmin and public page rendering with layout support
loginUniversal login for any user table
trongate_administratorsAdmin panel (create, edit, delete users)
trongate_emailSend emails via SMTP
trongate_controlModule management and SQL import
trongate_securityPermission checking, method-level access control
trongate_tokensAPI token generation, validation, lifecycle
urlURL generation, redirects, anchor tags
utilitiesBlock URL access, CORS handling, segment helper
validationForm validation, error display, CSRF protection
welcomeDefault landing page

Every one of these is a module. Every one follows the same pattern: folder → controller → done.

How Helpers Became Modules

In earlier versions of Trongate, helper functions lived inside engine/tg_helpers/ as full function definitions that were loaded on every request. That worked, but it meant PHP had to parse hundreds of lines of helper code even when you only needed truncate_str() once.

Today, those helper files are thin routing wrappers. Each function simply forwards the call to its corresponding module via Modules::run():

The real logic lives in the string_service module. The helper file is just a map. The result?

  • Engine size: ~ approximately 1,200 lines of core PHP across the entire framework
  • Bootstrap overhead: Near zero - helpers parse as lightweight function stubs
  • Module logic: Loaded only when called, not on every request

What This Means for You

As a developer, nothing changes. You still call truncate_str(), current_url(), $this->db->get() - exactly as before.

But under the hood, the framework is leaner than ever. The engine/ directory - the beating heart of Trongate - now contains only four PHP files totalling roughly 1,200 lines. Everything else is a module, loaded lazily, invoked only when needed.

Your application code doesn't feel any of this. It just runs faster.

Takeaway: A module is a folder. A folder is a module. Database? Module. Templates? Module. Helper functions? Modules. The entire framework is just folders and controllers, glued together with Native PHP. That's the whole trick.

We're continually improving the Trongate documentation. If anything is incorrect, unclear, incomplete, or could be better, we'd genuinely appreciate your input.

Share your thoughts in the Documentation Feedback.

Leave Feedback About This Page