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

Controller Files

Every module gets one controller file. Every controller file contains one PHP class. The boss.

Trongate v2 killed the controllers/ subfolder.

We got rid of this →

And, now we do this →

You’re welcome.

Where They Live Now

The text above demonstrates some file and directory locations for a hypothetical 'users' module.

Naming Rules

Thing Rule Example
Module Directory Name lowercase, usually plural luxury_wristwatches
Controller File Name UppercaseFirst, snake_case + .php Luxury_wristwatches.php
Class Name UppercaseFirst, snake_case Luxury_wristwatches

Bare Minimum Controller

Visit: https://yoursite.com/dice/roll → rolls a die. No config. No YAML. No drama.


Real-World Example: Users

Trongate v2 rejects third-URL-segment magic!

Other PHP frameworks encourage you to write code like this:

The assumption, with this kind of code, is that the third URL segment will contain a numeric value ...and that's a problem!

The primary aim of Trongate v2 is to be the world's most AI-friendly framework. In order to achieve this goal, we're aiming for zero AI halluncinations.

One of the strategies used by Trongate v2 to prevent hallucinations is to encourage the adoption of guessable code.

Therefore, variables from the URL have to be explicitly declared using the helper function. For example:


Constructors? Optional.

If you don't need one, don’t write one.

On the other hand, if you do need a constructor, here's some guidance: Mastering Constructors

Need CORS? Read this.

Multiple Classes? Don’t do it!

Want another class? Make a child module. Avoid having multiple controller files in the same folder.

Copy. Paste. Works. No require_once hell.

Third-Party? Sure. But Why?

Need Guzzle? Stripe? Fine. Drop Composer in vendor/, autoload it:

But 99% of the time Native PHP wins. Faster. Cleaner. No 3 AM updates.

Namespaces? Only When Forced

Using Packagist? Use their PascalCase namespaces. Otherwise? Snake case everything.

One file. One class. Native PHP rules!