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.

The Underscore Naming Convention

Trongate employs the underscore naming convention as a mechanism to control method accessibility. This convention involves prefixing method names with an underscore character to prevent them from being accessed directly via a URL. For example:

Methods prefixed with an underscore are effectively restricted from public URL invocation, while still remaining accessible within the framework's modular architecture.

How It Works

In Trongate, modules are designed to be independent yet interoperable. Developers can easily load one module from another, as demonstrated in the example below:

Information regarding how modules can load and use other modules is provided within the, Modules Calling Modules chapter of this documentation.

While methods prefixed with an underscore cannot be accessed via a URL, they remain fully accessible within the framework. This ensures that developers can invoke methods across modules without exposing sensitive functionality to external requests.

Addressing Common Misconceptions

A common misconception is that the underscore naming convention renders methods "private" or "protected." However, this is not the case. In object-oriented programming:

  • Private methods can only be invoked within their containing class.
  • Protected methods can be accessed by their containing class and any classes that extend it.

Since modules in Trongate are entirely independent, invoking a method from one module in another would be impossible unless the method is explicitly declared as public. The underscore naming convention does not alter a method's visibility within the codebase; rather, it restricts direct URL access to ensure security and maintainability.

Some developers mistakenly associate the underscore naming convention with outdated practices, particularly because earlier PHP frameworks (e.g., Zend Framework 1, early versions of CodeIgniter, and Yii1) used similar approaches but later replaced them with full access modifiers. However, this assumption is incorrect and reflects a misunderstanding of Trongate's unique architecture. The underscore naming convention is a deliberate and integral part of the framework's design, not a relic of outdated practices.

Without this convention, developers would need to rely on additional configuration mechanisms, such as YAML files, to explicitly specify which methods can or cannot be accessed via URLs. The underscore naming convention simplifies this process, providing a clean and efficient way to secure methods from direct URL access.

More information pertaining to this topic is offered here.

×