1. Go to this page and download the library: Download mrjulio/rapture-router library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mrjulio / rapture-router example snippets
// add multiple routes
$router = new \Rapture\Router\Router();
$router->addRoutes([
['user-add', 'GET', '/user/add', 'User\Add'],
['user-edit', 'GET', '/user/edit/{id:\d+}[/{check}]', 'User\ViewDate'],
])->processRoutes(); // run once after each routes have been added
// add group
$router->addGroup(
'/admin/user',
[
['search', 'GET', '/search', 'Search'],
['view', 'GET', '/view/{id:\d+}', 'View'],
],
)->processRoutes();
// ...is same as...
$router->addRoute('admin-user-search', 'GET', '/admin/user/search', 'Admin\User\Search');
$router->addRoute('admin-user-view', 'GET', '/admin/user/view/{id:\d+}', 'Admin\User\View')
$router->processRoutes();
// [Router::FOUND, 'User\View', ['id' => 100]],
$router->route('GET', '/user/edit/100');
// [Router::NOT_FOUND],
$router->route('POST', '/user/edit/100');
// [Router::NOT_FOUND],
$router->route('GET', '/user/edit/100/'); // trailing slash
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.