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

What Are Helpers?

A helper function is a standalone PHP function that performs a specific task. It lives outside any class or module. No instantiation. No dependency injection. You call it, it works, you move on.

Trongate v2 comes with dozens of them — for URLs, forms, strings, flashdata, utilities, and more.

How Trongate Handles Helpers

Every PHP framework has helpers. The difference is how they load them.

CodeIgniter 3 requires you to declare which helpers to load via a config file or a $this->load->helper() call. Load a helper file and you get every function in that file — parsed, tokenised, and ready to go, whether you use them all or not.

Trongate v2 takes a different approach. Each helper function is a thin dispatcher that forwards the call to a dedicated service module. The real logic lives in modules/, not in the helper file.

The helper file stays small and fast to parse. The heavy lifting happens inside a service module — loaded only when the function is actually called.

Trongate's unique approach to loading of helpers reduced source, within the engine directory, from ~80 KB to ~10 KB. That's roughly 87.5% less code for PHP to lex and parse before your application code runs. It's one of the key ingredients that gives Trongate such fast benchmarks.


Why This Matters

The approach delivers two practical wins:

1. Faster Bootstrap

PHP must lex, tokenise, and parse every included file before any application code runs. Smaller helper files mean less work per request and measurable throughput gains, particularly on simple endpoints.

2. Easy Customization

Want to emit Tailwind classes? Or to add a data- attribute? The logic lives in service modules, not in engine/. Change the module method, and the helper follows. No forking. No core modifications. No hassle.


The Bottom Line

Most frameworks require you to load helpers explicitly and pay the cost upfront. Trongate loads helper definitions eagerly but defers the actual logic until it's needed.

Next: the Helpers Overview for a practical look at each helper file.

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