URI Routing
What is URI Routing?
Api.php and Web.php
Api.php and Web.phpDefining Routing Rules in PHPFast
Examples
$routes->get('users/', 'UsersController::list');
$routes->post('users/create', 'UsersController::create');
$routes->get('users/(:num)', 'UsersController::view:$1');
$routes->put('users/edit/(:num)', 'UsersController::edit:$1');
$routes->delete('users/delete/(:num)', 'UsersController::delete:$1');
$routes->get('admin', 'AdminController::index', [\App\Middleware\AuthMiddleware::class]);Understanding Route Structure
Defining Routes with HTTP Methods
Using Placeholders for Dynamic URLs
1. (:any) - Matches any string (except /).
(:any) - Matches any string (except /).2. (:segment) – Matches a single URL segment (excluding /).
(:segment) – Matches a single URL segment (excluding /).3. (:num) - Matches only numeric values.
4. (:alpha) – Matches only alphabetic characters (A-Z, a-z).
(:alpha) – Matches only alphabetic characters (A-Z, a-z).5. (:alphanum) – Matches alphanumeric characters (A-Z, a-z, 0-9).
6. (:hash) – Matches a 32-character hexadecimal hash value.
Global Options
Last updated
Was this helpful?