-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.php
53 lines (40 loc) · 1.23 KB
/
example.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
44
45
46
47
48
49
50
51
52
53
<?php
require(__DIR__."/class.router.php");
$router = new Router();
$router->get('/api/example','example_one');
$router->get('/api/example/{id}','example_two');
$router->get('/api/example/thing','example_three');
$router->get('/api/example/{id}','example_two');
$router->get('/api/example/{id}/two/{id}','example_four');
$router->put('/api/example/{id}','example_five');
$router->post('/api/example/{id}','example_six');
$router->delete('/api/example/{id}','example_seven');
function example_one() {
echo "[GET] Example One" . PHP_EOL;
}
function example_two(Request $request, $one) {
echo "[GET] Example Two" . PHP_EOL;
echo $one . PHP_EOL;
}
function example_three() {
echo "[GET] Example Three" . PHP_EOL;
}
function example_four(Request $request, $one, $two) {
echo "[GET] Example Four" . PHP_EOL;
echo $one . PHP_EOL;
echo $two . PHP_EOL;
}
function example_five(Request $request, $one) {
echo "[PUT] Example Five" . PHP_EOL;
echo $one . PHP_EOL;
}
function example_six(Request $request, $one) {
echo "[POST] Example Six" . PHP_EOL;
echo $one . PHP_EOL;
print_R($request->body);
}
function example_seven(Request $request, $one) {
echo "[DELETE] Example Seven" . PHP_EOL;
echo $one . PHP_EOL;
}
$router->start();