-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
41 lines (30 loc) · 1.41 KB
/
index.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
<?php
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/config.php';
use DevStream\Controllers\AuthController;
use DevStream\Controllers\StreamsController;
use DevStream\Controllers\UsersController;
use League\Route\Router;
$request = Laminas\Diactoros\ServerRequestFactory::fromGlobals(
$_SERVER, $_GET, $_POST, $_COOKIE, $_FILES
);
// form spoofing
if (isset($request->getQueryParams()['_method'])) {
$request = $request->withMethod($request->getQueryParams()['_method']);
}
$router = new Router;
$router->get('/', [StreamsController::class, 'index']);
$router->get('/streams/create', [StreamsController::class, 'create']);
$router->post('/streams', [StreamsController::class, 'store']);
$router->get('/streams/{id}', [StreamsController::class, 'show']);
$router->put('/streams/{id}', [StreamsController::class, 'update']);
$router->get('/streams/{id}/edit', [StreamsController::class, 'edit']);
$router->get('/users/{id}', [UsersController::class, 'show']);
$router->get('/register', [UsersController::class, 'create']);
$router->post('/register', [UsersController::class, 'store']);
$router->get('/login', [AuthController::class, 'create']);
$router->post('/login', [AuthController::class, 'store']);
$router->get('/logout', [AuthController::class, 'destroy']);
$response = $router->dispatch($request);
// send the response to the browser
(new Laminas\HttpHandlerRunner\Emitter\SapiEmitter)->emit($response);