no-framework-tutorial/implementation/09/config/container.php

24 lines
749 B
PHP
Raw Normal View History

2022-05-19 21:39:08 +00:00
<?php declare(strict_types=1);
2022-05-20 22:57:02 +00:00
use DI\ContainerBuilder;
use Laminas\Diactoros\Response;
use Laminas\Diactoros\ServerRequestFactory;
use Lubian\NoFramework\Service\Time\Clock;
use Lubian\NoFramework\Service\Time\SystemClock;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
2022-05-19 21:39:08 +00:00
2022-05-20 22:57:02 +00:00
use function FastRoute\simpleDispatcher;
$builder = new ContainerBuilder;
$builder->addDefinitions(
[
ServerRequestInterface::class => fn () => ServerRequestFactory::fromGlobals(),
ResponseInterface::class => fn () => new Response,
FastRoute\Dispatcher::class => fn () => simpleDispatcher(require __DIR__ . '/routes.php'),
Clock::class => fn () => new SystemClock,
]
);
2022-05-20 22:57:02 +00:00
return $builder->build();