1. Go to this page and download the library: Download ifcanduela/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/ */
ifcanduela / router example snippets
$router = new ifcanduela\router\Router();
$router->get("/")->to("my_controller");
/** @var ifcanduela\router\Router $r */
$r->get("/")->to("home");
$r->group("/admin", function (ifcanduela\router\Group $g) {
$g->get("/dashboard")->to("admin@dashboard");
});
// `$this` can also be used
$this->post("/save")->to("admin@save");
$router = new ifcanduela\router\Router();
$router->loadFile("routes.php", "r");
$router->group("/admin", function (ifcanduela\router\Group $g) {
$g->loadFile("admin-routes.php");
$g->group("/settings", function (ifcanduela\router\Group $g) {
$g->loadFile("admin-settings-routes.php");
});
});
$group = new Group();
$group->from("/home")->to("home_controller");
$group->get("/login")->to("login_form");
$group->post("/login")->to("login_submit");
$group = new Group();
$group->routes([
Route::from("/home")->to("home_controller"),
Route::get("/login")->to("login_form"),
Route::post("/login")->to("login_submit"),
]);