joomla/router
Joomla Framework Router registers application routes and dispatches incoming request URIs to controller methods. PHP 8.1+ compatible, install via Composer (joomla/router ~3.0). Suitable for building clean, maintainable routing in PHP apps.
The Joomla Router allows parameters inside the defaults collection that don't have to match a placeholder in the route path. This means, you can use the defaults array to specify extra parameters that will then be accessible for use in your Request object or controller.
use Joomla\Router\Router;
$router = new Router;
$router->addRoute(
'GET',
'/user/:id',
'UserController@show',
array(
'id' => '(\d+)'
),
array(
'id': 0,
'username': 'Fred'
)
);
As you can see, the username variable was never defined inside the route path, but you can still access its value from the return once the URL is parsed.
How can I help you explore Laravel packages today?