golem/auth-storage-symfony

为 Golem Auth 的 Symfony 会话存储适配器

5.0.0 2023-02-15 20:33 UTC

This package is auto-updated.

Last update: 2024-09-15 23:57:59 UTC


README

Latest Stable Version Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight

为 Golem Auth 的 Symfony 会话存储适配器

安装

通过 Composer

$ composer require golem/auth-storage-symfony

用法

按照Golem Auth的文档创建用户模型和用户仓库类。

use ;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;

// configure the symfony session as usual
$session_storage = new NativeSessionStorage(array(), new NativeFileSessionHandler());
$session = new Session($session_storage);

$storage = new \Golem\Auth\Storage\SymfonySessionStorage($session);
// get an instance of your user repository however you need to
$userRepository = new UserRepository($database_connection);
$auth = new \Golem\Auth($storage, $userRepository);

测试

$ composer test

许可证

MIT 许可证(MIT)。请参阅许可证文件获取更多信息。