ellipse/session
Composer 安装命令:
composer require ellipse/session
包简介
Psr-15 middleware allowing to use session with Psr-7 request and response
关键字:
README 文档
README
This package provides a Psr-15 middleware managing session. It works out of the box using the session configuration values, yet it is suited to the Psr-7 request/response abstraction.
Require php >= 7.0
Installation composer require ellipse/session
Run tests ./vendor/bin/kahlan
Using the session middleware
<?php use Ellipse\Dispatcher; use Ellipse\Session\SessionMiddleware; // By default SessionMiddleware uses php session configuration values. $middleware = new SessionMiddleware // Will call php session_set_save_handler($handler) before starting the session. ->withSaveHandler($handler) // Will call php session_name('session_name') before starting the session. ->withName('session_name') // Will call php session_save_path('/session/save/path') before starting the session. ->withSavePath('/session/save/path') // Will call php session_cache_limiter('public') before starting the session. ->withCacheLimiter('public') // Will call php session_cache_expire(60) before starting the session. ->withCacheExpire(60) // Will call php session_set_cookie_params(3600, '/path', 'domain', true, true) before starting the session. ->withCookieParams([ 'lifetime' => 3600, 'path' => '/path', 'domain' => 'domain', 'secure' => true, 'httponly' => true, ]); // Build a dispatcher using the session middleware. $dispatcher = new Dispatcher([ $middleware, // Next middleware have access to the request Ellipse\Session::class attribute. new class implements MiddlewareInterface { public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) { // Session data is attached to the Ellipse\Session::class request attribute. $session = $request->getAttribute(Ellipse\Session::class); // Return the session id (session_id()) $session->id(); // Regenerate the session id (session_regenerate_id(bool $delete_old_session = false)) $session->regenerate_id(); // Set a session value. $session->set('key', 'value'); // Set a session value only for the next session. $session->flash('key', 'value'); // Return whether a session value is set. $session->has('key'); // Return an array of all the session data. $session->all(); // Return the value associated to the given key. $session->get('key'); // Return a default value when the given key is not set. $session->get('notset', 'default'); // Unset a session value. $session->unset('key'); // Unset all session value. $session->delete(); } } ]);
ellipse/session 适用场景与选型建议
ellipse/session 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 150 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 03 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「middleware」 「session」 「psr-7」 「psr-15」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ellipse/session 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ellipse/session 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ellipse/session 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Secure session middleware for Slim 3 framework
Model of a web-based resource
Interfaces for web resource models and services to retrieve and create them
Non-I/O blocking PHP SessionHandler implementation using Nette/Caching with DI Extension for Nette framework
Interface for a factory to create Psr\Http\Message\StreamInterface objects
统计信息
- 总下载量: 150
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-11