The RouteRegistry class is a singleton that allows registration and retrieval of routable objects or functions.
Usage Example:
use \Emma\Http\Mappings\PatchMapping;
$routables = [
IndexController::class,
...
//example: Adding your function directly to the array.
#[PatchMapping('/update/summary/{id:[0-9]*}')]
function middlewareQuickPatch(): void {
$result = ['status' => true, 'data' => 'ABCD'];
die(json_encode($result));
},
];
RouteRegistry::getInstance()->setRoutables($routables); //Register ALL
ADVANCED USERS
can have there arrays of functions and/or classes in different file and includes those file with array_merge()
can have there arrays of functions and/or classes in different file and includes those file with array_merge()
$routables = array_merge(
(array) include "directory_to_array_file/class_file.php",
(array) include "directory_to_array_file/direct_method_file.php",
(array) include "directory_to_array_file/functions_file.php",
);
RouteRegistry::getInstance()->setRoutables($routables); //Register ALL
WHERE :
class_file.php:
=====================
return [
IndexController::class,
...
];
Other file will simply follow class_file example...