-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
40 lines (34 loc) · 1.54 KB
/
index.php
File metadata and controls
40 lines (34 loc) · 1.54 KB
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
<?php
// Require composer autoloader
require __DIR__ . '/vendor/autoload.php';
// Create Router instance
$router = new \Mezon\Router\Router();
// Define routes
$router->addRoute('/', function(string $route) {
print "$route\n";
print "Hello, World!\n";
}, 'GET');
$router->addRoute('/[i:digit]-[s:name].html', function(string $route, array $parameters) {
print "$route\n";
print_r($parameters);
}, 'GET');
// $router->addRoute('/static-route/', 'MySite::someStaticMethod');
// $router->addRoute('/contacts/', function(){}, 'POST'); // this handler will be called for POST requests
// $router->addRoute('/contacts/', function(){}, 'GET'); // this handler will be called for GET requests
// $router->addRoute('/contacts/', function(){}, 'PUT'); // this handler will be called for PUT requests
// $router->addRoute('/contacts/', function(){}, 'DELETE'); // this handler will be called for DELETE requests
// $router->addRoute('/contacts/', function(){}, 'OPTION'); // this handler will be called for OPTION requests
// $router->addRoute('/contacts/', function(){}, 'PATCH'); // this handler will be called for PATCH requests
// $router->addRoute('/contacts/', function(){});
// $router->addRoute('/*/', function(){});
// $router->addRoute('/index/', function(){});
// Test it!
// $callback = $router->getCallback('/');
// $callback = $router->getCallback('/100-test.html');
// var_dump($callback);
// Run and Test it!
$router->callRoute('/');
$router->callRoute('/100-test.html');
// Run it!
// $path = $_SERVER["REQUEST_URI"];
// $router->callRoute($path);