__construct()
public function __construct(?string $module_name = null)
Description
Constructor for the Trongate base controller. Sets the module name for the current controller instance. If no module name is provided, auto‑detects from the class name (e.g., a class named Products becomes module products).
Note: The framework automatically passes the module name when instantiating controllers via URL routing. You only need to call the constructor manually when creating controller instances programmatically.
Parameters
| Parameter | Type | Description | Default | Required |
|---|---|---|---|---|
| module_name | string|null | The module name for this controller instance. If null, derived from the class name. | null | No |
Return Value
| Type | Description |
|---|---|
| void | Constructor does not return a value. |
Example Usage
PHP
<?php
// Automatic instantiation by framework (URL: /products/show/15)
// Inside Products.php controller:
class Products extends Trongate {
public function __construct(?string $module_name = null) {
parent::__construct($module_name); // REQUIRED
// Your initialization code...
}
}
// Manual instantiation (rare)
$controller = new Trongate('custom_module');