-
Notifications
You must be signed in to change notification settings - Fork 311
/
Copy pathroutes.php
25 lines (17 loc) · 872 Bytes
/
routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
$router = new Framework\Router;
// Homepage example
$router->add("/", ["controller" => "home", "action" => "index"]);
// Catch-all example
$router->add("/{controller}/{action}");
// Examples with custom route variables
$router->add("/{title}/{id:\d+}/{page:\d+}", ["controller" => "products", "action" => "showPage"]);
$router->add("/product/{slug:[\w-]+}", ["controller" => "products", "action" => "show"]);
// Example with namespace
$router->add("/admin/{controller}/{action}", ["namespace" => "Admin"]);
// Example with HTTP method
$router->add("/{controller}/{id:\d+}/destroy", ["action" => "destroy", "method" => "post"]);
// Example with middleware
$router->add("/{controller}/{id:\d+}/show", ["action" => "show", "middleware" => "example"]);
$router->add("/{controller}/{id:\d+}/edit", ["action" => "edit", "middleware" => "one|two"]);
return $router;