-
Notifications
You must be signed in to change notification settings - Fork 0
/
route.php
43 lines (35 loc) · 1.06 KB
/
route.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
use App\Route;
use App\Controllers\Index;
use App\Controllers\Test;
use App\Controllers\Crud;
use App\Controllers\DynamicRoute;
use App\Middlewares\ShouldAuthenticate;
/**
* @author Earl Sabalo
*
* This is the route file where you can define your routes
*
* ex:
* $route->get('/test', function() {
* return 'test';
* });
*/
$routes = new Route();
$routes->get('/hello-world', function() {
return 'Hello World';
});
$routes->get('/', [Index::class, 'index']);
$routes->get('/index/test', [Index::class, 'test']);
$routes->get('/test', [Test::class, 'index']);
$routes->resource('/resource', App\Controllers\Resource::class);
$routes->resource('/add-user', Crud::class);
$routes->get('/test/{id}', function ($id) {
echo "ID: $id";
});
$routes->get('/dynamic-route/{id}', [DynamicRoute::class, 'index']);
$routes->get('/dynamic-route/show/{name}', [DynamicRoute::class, 'show']);
$routes->get('/dynamic-route/{id}/show/{name}', function($id, $name) {
echo "ID: $id, Name: $name";
})->middleware( new ShouldAuthenticate() );
$routes->loadRoutes();