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

24 lines
749 B
PHP
Raw Normal View History

2022-05-23 20:08:50 +00:00
<?php declare(strict_types=1);
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;
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,
]
);
return $builder->build();