Documentation

Router
in package

Weaver Framework - Router Class

This class is responsible for routing requests to the appropriate controllers and actions.

Table of Contents

Properties

$routes  : array<string|int, mixed>
Associative array to store the registered routes.

Methods

addRoute()  : mixed
Add a new route to the router.
dispatch()  : void
Dispatch the request to the appropriate controller and action.
routeRequest()  : void
Route the request to the appropriate controller and action.
show404Error()  : void
Display a 404 error page when the route is not found.

Properties

$routes

Associative array to store the registered routes.

private array<string|int, mixed> $routes = []

Methods

addRoute()

Add a new route to the router.

public addRoute(string $route, string $handler) : mixed
Parameters
$route : string

The URL route to match.

$handler : string

The controller and action to execute (e.g., "HomeController@index").

dispatch()

Dispatch the request to the appropriate controller and action.

public dispatch() : void

routeRequest()

Route the request to the appropriate controller and action.

private routeRequest(string $url) : void
Parameters
$url : string

The requested URL.

show404Error()

Display a 404 error page when the route is not found.

private show404Error() : void

        
On this page

Search results