-
Notifications
You must be signed in to change notification settings - Fork 0
Routing
AngelNovo edited this page Aug 10, 2024
·
3 revisions
As of version 0.0.1.alpha1, there's only support for 'GET' and 'POST' handling
A raw route can be defined as a route without any under the hood middleware/effect.
This types of routes should be created in /routes/raw.php
A static route can be defined as a route with no dynamic parameters
// Including the route handler
use lib\components\Route;
/*
The class instance must follow the following notation -> ClassName::class
*/
Route::Get(string $route, $class_instance, string $functionName);
// Same with POST
Route::Post(...)The declaration of a dynamic route is identical to a static route, it's the route string that changes
/*
Everything inside of '{' and '}' will be treated as a dynamic parameter and
will be obtained as a string
*/
'/user/{id}'
'/user/{id:}'/*
In this case, id will be converted to an integer and the slug to a string
*/
'/user/{id:int}/article/{slug:string}'-
int- If the route contains an invalid
integer, 0 will be passed to the controller
- If the route contains an invalid
-
string- this type is not necessary, as every untyped param is considered a string
The Not found route declaration is identical to regular routes.
If the route string contains *.* however, it is considered a not found route regardless
of the method.