Introduction
Basic Concepts
Understanding Routing
Controllers
Views
Assets
Modules Calling Modules
Parent & Child Modules
Database Operations
Modules within Modules
Templates & Themes
Helpers Explained
Form Handling
Working with Files
The Module Import Wizard
Authorization & Authentication
The API Explorer
If you’ve found an error, spotted something missing, or feel a section could be clearer or better explained, we’d love to hear from you. Your feedback helps keep the documentation accurate and useful for everyone.
Please report issues or suggest improvements on GitHub. Community input is invaluable in making the docs stronger.
Not comfortable with GitHub? No problem — you can also get in touch with us directly via our contact form. We welcome all feedback.
Other Helpful Features
Trongate includes several useful features that are not part of any specific helper file or class but play an integral role in streamlining web development. These features can be accessed from within any module controller or view file.
The Anchor Function
The anchor() function generates a clickable text link pointing to a URL relative to BASE_URL
.
For instance, if the website example.com has a homepage located at:
A contact page at https://example.com/contact
can be linked using:
This function accepts up to three parameters:
- $target_url ~ The destination URL.
- $text ~ The displayed link text.
- $attributes (optional) ~ An array of key-value pairs added to the opening 'a' tag.
This function supports both internal and external links by providing a full URL as an argument.
Security Note: The anchor() function does not escape the link text. For user-generated or database content, consider combining with the out() function to prevent XSS attacks:
When using HTML in links (such as Font Awesome icons), make sure the content is from a trusted source:
For user-generated content, use in combination with the out() function. For example:
The IP Address Function
The ip_address() function returns the IP address of the current visitor. Syntax:
Example usage in a view file:
Generating Random Strings
The make_rand_str() function generates random strings. Example:
The first argument specifies the string length. Passing true as a second argument ensures uppercase output:
Characters prone to misinterpretation (e.g., '0', '1', 'l') are excluded for clarity, particularly in scenarios where users read codes aloud.
APPPATH
The APPPATH
constant returns the absolute file path of the application directory. Example:
Within a view file, the APPPATH
can be rendered using PHP short tags, like so:
The BASE_URL
constant is also available, returning the main website URL as defined in config.php
:
The JSON Function
The json() function provides a visual representation of data within controllers or views. Syntax:
The optional second argument, when set to true, terminates script execution after displaying the data.
Example usage in a view file:
Sample output:

json()
function.The Out Function
The out() function escapes and formats strings for safe output in different contexts. Parameters:
- $input ~ The string to escape.
- $encoding (optional) ~ Character encoding (default: 'UTF-8').
- $output_format (optional) ~ Output format: 'html' (default), 'xml', 'json', 'javascript', or 'attribute'.
Example 1: Safe Output from JSON Data
Example 2: Securing Database Output
More details pertaining to the out() function are available from here.