krisell/laravel-session-migrator
Composer 安装命令:
composer require krisell/laravel-session-migrator
包简介
Migrate Laravel session serialization method and driver without dropping any sessions.
README 文档
README
Migrate Laravel session driver or serialization method in production without dropping sessions.
Installation
composer require krisell/laravel-session-migrator
Features
This package allows production applications to update some of the session configuration without dropping any active sessions and signing users out. More specifically, two session configuration options can be migrated:
-
Session serialization method (
phporjson), regardless of driverLaravel 9 introduced the option to serialize session data using
jsonrather than php'sserialize, and might be preferred both from a security perspective and performance-wise. The method is changed by specifying'serialization' => 'json'inconfig/session.php, but changing that in a production app would normally cause all active sessions to be invalidated and users to be signed out. With this package, this setting can be migrated transparently to users. -
Session driver (from
fileorcookie)This package also allows to define a driver being migrated from, such that a new driver can be used without dropping any session data (technically, the old driver is used as a fallback
readsource, but allwritesare performed against the new driver).Note that currently, only the
fileandcookiedrivers are supported as being migrated from.
Usage
Installing the package intentionally doesn't activate any of the migration features. In order to perform a migration, update the session configuration to the new wanted settings, and then also perform one of the following:
- Add the following entry to your
config/session.phpfile:
'migrate' => [ 'serialization' => true, // Enables transparent serialization method migration 'driver' => 'file' // Session driver you are migrating from ],
- Alternatively, you can set the following two environment variables:
SESSION_MIGRATE_SERIALIZATION=true
SESSION_MIGRATE_DRIVER=file
You can of course choose to only use the serialization migration, or only the driver migration. It should be very rare that one need to migrate both these at the same time, although that is also supported.
Note specifically that migrate.driver is the driver you are migrating from, i.e. the previously used driver. The
new driver or serialization method is configured just as normal, in the config file or environment variables.
You only need this package during a short transition period where your application might still have session data using the old format. The length of this depends on your session lifetime. As an example, if your session expires after 2 hours, you only need to run this package in production for those two hours, although keeping it around longer does no harm. For performance reasons, you should certainly disable and preferable remove this package eventually after the transition has been completed.
Pre-production applications
There is no reason to use this package in pre-production applications or local environments, execept of course for testing before using live. If dropping sessions doesn't matter in your use case, simply update the session configuration as normal and skip this package.
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email martin.krisell@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
krisell/laravel-session-migrator 适用场景与选型建议
krisell/laravel-session-migrator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「krisell」 「laravel-session-migrator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 krisell/laravel-session-migrator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 krisell/laravel-session-migrator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-22