rnr1721/le7-cookie-wrapper
Composer 安装命令:
composer require rnr1721/le7-cookie-wrapper
包简介
Wrapper for $_SESSION and cookies for le7 PHP MVC framework or any PHP project
README 文档
README
Wrapper for session and cookies for le7 PHP MVC framework or any PHP project
Requirements
- PHP 8.1 or higher.
- Composer 2.0 or higher.
What it can?
- CRUD for cookies
- CRUD for session variables
There are set of interfaces and adapters for drive variables for $_SESSION and $_COOKIES:
- Core\Interfaces\CookieInterface interface - for cookie management
- Core\Interfacrs\SessionInterface interface - for session management
Installation
composer require rnr1721/le7-cookie-wrapper
Testing
composer test
Cookie adapters
- Core\Cookies\CookiesNative - default adapter, for use
- Core\Cookies\CookiesArray - data stored in array, not persistent (for testing)
- Core\Cookies\Cache - data stored in PSR cache (for testing)
You can write own implementation of CORE\Interfaces\CookieInterface All of these adapters need config, implementation of Core\Interfaces\CookieConfigInterface
- Core\Cookies\CookieConfigDefault
Of course, you can write own implementation, to load config from some source etc.
How use it?
use Core\Cookies\CookiesConfigDefault; use Core\Cookies\CookiesNative; // This is the default config $newConfig = [ 'domain' => '', 'httpOnly' => false, 'path' => '', 'isSecure' => false, 'time' => 0, 'sameSite' => 'Lax', ]; // Implementation of Core\Interfaces\CookieConfigInterface $config = new CookiesConfigDefault($newConfig); // Second case to add params // $config->setParams($newConfig); // Implementation of Core\Interfaces\CookieInterface $cookies = new CookiesNative($config); // Before operations with cookies you can set more concrete params // These params will override defaults // $cookies->setPath('/'); // $cookies->setHttpOnly(true); // $cookies->setSameSite('Lax'); // $cookies->setSecure(true); // $cookies->setTime(3600); $cookies->get('mycookie'); //return cookie value by key; $cookies->get('mycookie','default'); //return cookie value by key or default; $cookies->has('mycookie'); // return bool if cookie exists or not $cookies->delete('mycookie'); // delete cookie
Session adapters
Also, you can manage your session variables. It implementation of Core\Interfaces\SessionInterface
- Core\Session\SessionNative // Native PHP session management
- Core\Session\SessionArray // Store in array, not persistent, for testing
- Core\Session\SessionCache // Store in cache, not persistent, for testing
of course, you can write own adapter to store session in memcache or Redis etc.
How it use?
use Core\Session\SessionNative; $session = new Core\Session\SessionNative(); // start the session $session->start(); // Set param one with value test1 $session->set('one', 'test1'); // get param one or null if not exists $session->get('one'); // get param one or default value if not exists $session->get('one','default value'); // Return bool if param exists or not $session->has('one'); // Delete the param $session->delete('one'); // Return bool if session started or not $session->isStarted(); // Clear session $session->clear() // Destroy the session $session->destroy();
rnr1721/le7-cookie-wrapper 适用场景与选型建议
rnr1721/le7-cookie-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 129 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「session」 「component」 「cookie」 「le7」 「le7-framework」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rnr1721/le7-cookie-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rnr1721/le7-cookie-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rnr1721/le7-cookie-wrapper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
FSi DataSource Component
Secure session middleware for Slim 3 framework
Non-I/O blocking PHP SessionHandler implementation using Nette/Caching with DI Extension for Nette framework
Priveate for SkeekS CMS
Magento - Clean up session extension
统计信息
- 总下载量: 129
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-26