Domain: User, Session, EmailAddress, DTOs, repositories, services (PasswordHasher, TokenGenerator, Clock). Config: PHP-DI container definitions and Slim routes. Entry point: public/index.php with slim-bridge.
37 lines
1,012 B
PHP
37 lines
1,012 B
PHP
<?php
|
|
|
|
use App\Auth\BcryptPasswordHasher;
|
|
use App\Auth\Clock;
|
|
use App\Auth\PasswordHasher;
|
|
use App\Auth\RandomTokenGenerator;
|
|
use App\Auth\SystemClock;
|
|
use App\Auth\TokenGenerator;
|
|
use App\Auth\UseCases\AuthenticateUser\AuthenticateUser;
|
|
use App\Auth\UseCases\CreateSession\CreateSession;
|
|
use App\Auth\UseCases\Logout\Logout;
|
|
use App\Controllers\AuthController;
|
|
use App\Middleware\AuthMiddleware;
|
|
use DI\ContainerBuilder;
|
|
use Psr\Container\ContainerInterface;
|
|
|
|
$builder = new ContainerBuilder();
|
|
|
|
$builder->addDefinitions([
|
|
|
|
// Services
|
|
PasswordHasher::class => DI\create(BcryptPasswordHasher::class),
|
|
TokenGenerator::class => DI\create(RandomTokenGenerator::class),
|
|
Clock::class => DI\create(SystemClock::class),
|
|
|
|
// Use cases
|
|
AuthenticateUser::class => DI\autowire(),
|
|
CreateSession::class => DI\autowire(),
|
|
Logout::class => DI\autowire(),
|
|
|
|
// HTTP layer
|
|
AuthController::class => DI\autowire(),
|
|
AuthMiddleware::class => DI\autowire(),
|
|
|
|
]);
|
|
|
|
return $builder->build();
|