\Omega\Routing AbstractRouter

Abstract router class.

The AbstractRouter class serves as a foundation for implementing custom routers within the Omega Routing Package. It provides a set of methods to add routes for different HTTP methods and defines the dispatching behavior, allowing derived classes to handle route matching and execution of associated handlers.

Summary

Methods
Properties
Constants
get
post
put
delete
patch
options
any
dispatch
routes
No public constants found
No protected methods found
No protected properties found
No protected constants found
addRoute
No private properties found
No private constants found

Properties

$routes

$routes : array

Routes array.

Type

array<string|int, mixed> — Holds an array of routes.

Methods

get()

get(string  $path, mixed  $handler, ?string  $name = null) : \Omega\Routing\Route

Get method.

Parameters

string $path

Holds the path pattern for the route.

mixed $handler

Holds the handler for the route.

?string $name

Holds the route name or null.

Returns

\Omega\Routing\Route —

Returns the added Route instance.

post()

post(string  $path, mixed  $handler, ?string  $name = null) : \Omega\Routing\Route

Post method.

Parameters

string $path

Holds the path pattern for the route.

mixed $handler

Holds the handler for the route.

?string $name

Holds the route name or null.

Returns

\Omega\Routing\Route —

Returns the added Route instance.

put()

put(string  $path, mixed  $handler, ?string  $name = null) : \Omega\Routing\Route

Put method.

Parameters

string $path

Holds the path pattern for the route.

mixed $handler

Holds the handler for the route.

?string $name

Holds the route name or null.

Returns

\Omega\Routing\Route —

Returns the added Route instance.

delete()

delete(string  $path, mixed  $handler, ?string  $name = null) : \Omega\Routing\Route

Delete method.

Parameters

string $path

Holds the path pattern for the route.

mixed $handler

Holds the handler for the route.

?string $name

Holds the route name or null.

Returns

\Omega\Routing\Route —

Returns the added Route instance.

patch()

patch(string  $path, mixed  $handler, ?string  $name = null) : \Omega\Routing\Route

Patch method.

Parameters

string $path

Holds the path pattern for the route.

mixed $handler

Holds the handler for the route.

?string $name

Holds the route name or null.

Returns

\Omega\Routing\Route —

Returns the added Route instance.

options()

options(string  $path, mixed  $handler, ?string  $name = null) : \Omega\Routing\Route

Options method.

Parameters

string $path

Holds the path pattern for the route.

mixed $handler

Holds the handler for the route.

?string $name

Holds the route name or null.

Returns

\Omega\Routing\Route —

Returns the added Route instance.

any()

any(string  $path, mixed  $handler, ?string  $name = null) : \Omega\Routing\Route

Any method.

Parameters

string $path

Holds the path pattern for the route.

mixed $handler

Holds the handler for the route.

?string $name

Holds the route name or null.

Returns

\Omega\Routing\Route —

Returns the added Route instance.

dispatch()

dispatch() : mixed

Dispatches the router, matching the current request and executing the corresponding route handler.

Returns

mixed —

The result of the route handler.

addRoute()

addRoute(string  $method, string  $path, mixed  $handler, string|null  $name = null) : \Omega\Routing\Route

Add a route to the router.

Parameters

string $method

Holds the HTTP method for the route.

string $path

Holds the path pattern for the route.

mixed $handler

Holds the handler for the route.

string|null $name

Holds the route name or null.

Returns

\Omega\Routing\Route —

Return the added Route instance.