Class Router
This file manages the routing for incoming URLs. Returns a call (Controller->action()) for the specific route.
To use in conjunction with /src/config/routing.ini, where all the desired routes must be present.
Namespace: Kernel\Providers
Package: Kernel
Example:
Usage:
Located at app/Kernel/Providers/Router.php
Package: Kernel
Example:
[RoutingKey]
path = <desired_path> ; no leading slash
action = <Controller_Name>@<Action_Name> ; don't write "Controller", just its name
after_login = 1 ; (or 0. OPTIONAL and 0 by default.<br/>
This means: if on first attempt it has no permission, can the user be auto-redirected after login?)
method = "PUT|POST" ; (GET|PUT|POST|DELETE) OPTIONAL, "|" separated if multiple.
Will only enter if $_SERVER['REQUEST_METHOD'] matches
condition = '$_SERVER["HTTP_HOST"] == "localhost"' ; OPTIONAL.
If set, the code will be evaluated (function: eval()) as a further filter
default[animal] = dog
default[sound] = bark ; This is optional! but /zoo/:animal/:sound will match for /zoo, /zoo/<any_animal> and
/zoo/<any_animal>/<any_sound> all in only one route! (use it for things like /blogpost/:page/:number
with :page = page and :number = 1 as defaults. Hence /blogpost is page 1 and /blogpost/page/2 is page 2)Usage:
The [keys] MUST be unique throughout ALL routing.ini files.
The action omits the "Controller" part of the controller name.
Login@showLogin calls LoginController->showLogin(), \Core\Login@showLogin calls
\Core\LoginController->showLogin() and @test calls Controller->test()
Located at app/Kernel/Providers/Router.php
public static
array
|
public static
string
|
$uri
The request URI for this thread execution. (i.e., the URL in the browser) |