worldnewsgroup/serverless-session-handler
最新稳定版本:v1.0.5
Composer 安装命令:
composer require worldnewsgroup/serverless-session-handler
包简介
Enable PHP sessions using DynamoDB in Serverless
关键字:
README 文档
README
Provides a PHP session handler for AWS DynamoDB when hosting websites on Serverless.
Installation
Installation is easy via Composer:
$ composer require worldnewsgroup/serverless-session-handler
or add it manually to your composer.json.
Usage
Create a DynamoDB table with the following defintion (serverless resource definition):
resources: Resources: sessionTable: Type: AWS::DynamoDB::Table Properties: #BillingMode: PAY_PER_REQUEST TableName: ${self:service}-sessions AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - AttributeName: id KeyType: HASH
Verify the Serverless IAM roles or permissions are correct for connecting to that DynamoDB.
provider: iamRoleStatements: - Effect: Allow Action: - dynamodb:GetItem - dynamodb:PutItem - dynamodb:DeleteItem - dynamodb:DescribeTable Resource: - "Fn::GetAtt": [ sessionTable, Arn ]
In code, set up the handler. Use the standard access methods for PHP sessions.
use WorldNewsGroup\Serverless\ServerlessSession; require('vendor/autoload.php'); // put as close to the top (just under the require('vendor/autoload.php') is best) as possible ServerlessSession::getInstance('<dynamodb_table_name>', '<aws region>'); ... // set the Session variable token to 'jwt' $_SESSION['token'] = 'jwt';
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-17