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

Coding Style Guidelines

Trongate doesn’t wrap PHP in conventions, or abstractions. It is PHP - raw, fast, and unapologetic. This is Native PHP: code that runs like it was written by someone who actually loves the language.

Core Principles

  • Zero bloat. Zero abstraction.
  • Write PHP exactly as the creators of the language intended.
  • If it doesn’t make your code faster or clearer, it doesn’t belong.

The overwhelming majority of PHP’s built-in functions use snake_case. So should you.

Why Snake Case Wins

  • The overwhelming majority of PHP's core functions use snake_case, including :
  • array_merge()
    class_exists()
    file_get_contents()
    function_exists()
    str_replace()
    strip_tags()
    ...and more!
  • Snake case eliminates the eternal userId vs userID vs UserId holy wars.
  • Snake case reads naturally: get_user_by_id() > getUserByID().

Many PHP frameworks encourage the usage of camelCase. Unfortunately, camelCase introduces unnecessary ambiguity. Consider the following example, which compares camelCase PHP with Native PHP:

No debate. No style-guide meetings. Just simple code.

K&R Style - Because C Got It Right

PHP was built with the C programming language. We honor that. All official examples use Kernighan & Ritchie bracing:

  • Four spaces. No tabs. Ever.
  • Opening brace on same line.
  • Closing brace aligns with the command.

The Only Rules That Matter

  1. Consistency beats dogma.
  2. Clarity beats cleverness.
  3. Speed beats ceremony.