-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
69 lines (58 loc) · 1.68 KB
/
Copy pathbootstrap.php
File metadata and controls
69 lines (58 loc) · 1.68 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
declare(strict_types=1);
use A50\Container\ContainerFactory;
use A50\Container\ServiceProvider;
use A50\Http\Providers\HttpServiceProvider;
use A50\Http\Response\ResponseFactory;
use A50\Http\Router\Route;
use A50\Http\Router\RouterConfig;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
mb_internal_encoding('UTF-8');
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'stderr');
$rootDirectory = __DIR__;
define('ROOT', $rootDirectory);
require_once $rootDirectory . '/vendor/autoload.php';
final class HomePageAction implements RequestHandlerInterface
{
private ResponseFactory $responseFactory;
public function __construct(ResponseFactory $responseFactory)
{
$this->responseFactory = $responseFactory;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
return $this->responseFactory::html('<h1>Hello, world!</h1>');
}
}
final class ApplicationServiceProvider implements ServiceProvider
{
/**
*
*/
public static function getDefinitions(): array
{
return [];
}
/**
*
*/
public static function getExtensions(): array
{
return [
RouterConfig::class => static fn (RouterConfig $config) => $config->withRoute(
Route::get('/', HomePageAction::class)
->withName('home')
),
];
}
}
return static fn (): ContainerInterface => (new ContainerFactory())->build(
[
HttpServiceProvider::class,
ApplicationServiceProvider::class,
]
);