-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
31 lines (20 loc) · 873 Bytes
/
index.php
File metadata and controls
31 lines (20 loc) · 873 Bytes
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
<?php
declare(strict_types=1);
use Blutz\Html\Controller\CalculatorController;
use Blutz\Html\Controller\GerdController;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
include 'vendor/autoload.php';
$request = Laminas\Diactoros\ServerRequestFactory::fromGlobals();
$router = new League\Route\Router;
// map a route
$router->map('GET', '/', function (ServerRequestInterface $request): ResponseInterface {
$response = new Laminas\Diactoros\Response;
$response->getBody()->write('<h1>Hello, World!</h1>');
return $response;
});
$router->map('GET', '/controller', [new GerdController(), 'index']);
$router->map('GET', '/rechner', [new CalculatorController(), 'index']);
$response = $router->dispatch($request);
// send the response to the browser
(new Laminas\HttpHandlerRunner\Emitter\SapiEmitter)->emit($response);