generated from chicory/php-env
Compare commits
3 Commits
7c3593b3e5
...
a16f916b05
Author | SHA1 | Date | |
---|---|---|---|
a16f916b05 | |||
32af4da93c | |||
695cfa2fc3 |
@ -17,7 +17,8 @@
|
||||
"php-di/slim-bridge": "^3.4",
|
||||
"monolog/monolog": "^3.9",
|
||||
"slim/twig-view": "^3.4",
|
||||
"cuyz/valinor": "^2.1"
|
||||
"cuyz/valinor": "^2.1",
|
||||
"odan/session": "^6.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^2.1",
|
||||
|
@ -7,5 +7,11 @@
|
||||
"displayErrorDetails": true,
|
||||
"logErrors": true,
|
||||
"logErrorDetails": true
|
||||
},
|
||||
"session": {
|
||||
"name": "runx-session",
|
||||
"lifetime": 86400,
|
||||
"secure": true,
|
||||
"httpOnly": true
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ use CuyZ\Valinor\MapperBuilder;
|
||||
use DI\ContainerBuilder;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Logger;
|
||||
use Odan\Session\PhpSession;
|
||||
use Odan\Session\SessionInterface;
|
||||
use Odan\Session\SessionManagerInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\ResponseFactoryInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -81,5 +84,17 @@ return function (ContainerBuilder $builder): void {
|
||||
|
||||
return new RenderService($twig, $responseFactory, $logger);
|
||||
},
|
||||
|
||||
// Session
|
||||
SessionInterface::class => function (ContainerInterface $container) {
|
||||
/** @var Config $config */
|
||||
$config = $container->get(Config::class);
|
||||
|
||||
return new PhpSession($config->session->toArray());
|
||||
},
|
||||
|
||||
SessionManagerInterface::class => function (ContainerInterface $container) {
|
||||
return $container->get(SessionInterface::class);
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
@ -9,5 +9,6 @@ final class Config
|
||||
public function __construct(
|
||||
public readonly LoggerConfig $logger,
|
||||
public readonly ErrorHandlingConfig $errorHandling,
|
||||
public readonly SessionConfig $session,
|
||||
) {}
|
||||
}
|
||||
|
25
src/Infrastructure/Config/SessionConfig.php
Normal file
25
src/Infrastructure/Config/SessionConfig.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Runx\Infrastructure\Config;
|
||||
|
||||
final class SessionConfig
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $name,
|
||||
public readonly int $lifetime,
|
||||
public readonly bool $secure,
|
||||
public readonly bool $httpOnly,
|
||||
) {}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->name,
|
||||
'lifetime' => $this->lifetime,
|
||||
'secure' => $this->secure,
|
||||
'httponly' => $this->httpOnly,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user