The Trongate PHP Framework
Documentation
Introduction
Quick Start
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
Best Practices

Help Improve Our Docs

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.

Basic Example - Part 1

To clearly illustrate the purpose and functionality of the File Asset Manager, it is beneficial to examine a practical example. This section will guide through a straightforward example using the 'welcome' module that's included with all Trongate framework installations. The objective is to store a JavaScript file within the 'welcome' module and display a simple webpage that executes the module's internal JavaScript file.

The Starting Point

A fresh installation of a Trongate web application includes a module named 'welcome', which contains a controller file named Welcome.php. The 'Welcome' controller file comprises a class with a single method, as illustrated below:

The precise code contained within the 'Welcome' controller file will differ from the example shown. For brevity, elements such as access modifiers (e.g., public/private/protected), type hinting, return types, and doc blocks have been omitted.

Adding a New Method

Next, a new method will be added to the controller file. This method, named 'hello', will load a simple view file displaying the message 'hello world'. The updated controller code is as follows:

A Simple View File

Proceed by creating a view file containing basic HTML. The code sample below demonstrates a simple HTML template with the message 'Hello World' encapsulated within <h1> tags.

Displaying Content

To verify, open a web browser and navigate to the application homepage, followed by welcome/hello. The 'Hello World' message should be displayed on the screen.

browser screenshot
Screenshot taken from the URL, <base-url>welcome/hello
×