nofw / session-handlers
提供各种SessionHandlerInterface实现的软件包
v0.2.0
2017-04-18 14:13 UTC
Requires
- php: ^7.0
- psr/log: ^1.0
Requires (Dev)
- doctrine/cache: ^1.5
- henrikbjorn/phpspec-code-coverage: ^3.0
- phpspec/phpspec: ^3.0
- psr/cache: ^1.0
- psr/simple-cache: ^1.0
Suggests
- psr/log-implementation: Log errors of the PSR-6 and PSR-16 implementations
This package is auto-updated.
Last update: 2024-09-19 10:13:03 UTC
README
提供各种SessionHandlerInterface
实现的软件包。
安装
通过Composer
$ composer require nofw/session-handlers
用法
本软件包提供三种Session处理器实现
- PSR-6
- PSR-16
- Doctrine Cache
选择后端并实例化和注册处理器。
$cache = new ImaginaryCacheItemPool(); $handler = new \Nofw\Session\CacheSessionHandler($cache); session_set_save_handler($handler);
像平常一样使用您的会话。
日志记录
SessionHandlerInterface不允许抛出异常来指示失败。相反,它期望处理器返回空值(空字符串或false)。然而,PSR-X实现确实抛出异常。为了遵守接口并且不丢失检测失败的能力,这些实现接受PSR-3记录器作为其第二个构造函数参数,并实现LoggerAwareInterface
。
$cache = new ImaginaryCacheItemPool(); $logger = new Monolog\Logger('nofw') $handler = new \Nofw\Session\CacheSessionHandler($cache, $logger);
捕获的异常被记录为错误。
测试
$ make test
安全性
如果您发现任何安全相关的问题,请通过mark.sagikazar@gmail.com联系我们。
许可
MIT许可证(MIT)。请参阅许可文件获取更多信息。