gwk / dynamo-session-bundle

Symfony 2 的 DynamoDB 会话处理程序包

1.0 2016-02-11 09:54 UTC

This package is not auto-updated.

Last update: 2024-09-28 14:58:31 UTC


README

这个 Symfony 2.x 包允许您使用 DynamoDb Web 服务来存储您的会话

从版本 1.0 开始,此包需要 AWS PHP SDK 版本 3.0+,如果您使用的是 2.x SDK,请使用最新的 0.x 版本

安装

只需将以下内容添加到您的 composer.json 文件中

{
    "require": {
        "gwk/dynamo-session-bundle": "1.*"
    }
}

然后使用 composer 安装包

composer.phar update gwk/dynamo-session-bundle

现在将包添加到您的 app/AppKernel.php 中

$bundles[] = new GWK\DynamoSessionBundle\GWKDynamoSessionBundle();

配置

将以下配置设置添加到您的 app/config/config.yml 中

framework:
    session:
        handler_id: dynamo_session_handler

gwk_dynamo_session:
    table: my_session_table # DynamoDb Table to store sessions in
    locking_strategy: pessimistic # See AWS PHP documentation for valid values
    # dynamo_client_id: my_dynamodb_service # If you already use DynamoDb and you have a AWS\DynamoDb\DynamoDbClient service, you can make the session handler use it
    automatic_gc: true # Whether to use PHP's internal automatic garbage collection. The AWS sdk doesn't recommend it but doesn't explain why
    gc_batch_size: 25 # Maximum number of sessions the garbage collector deletes when garbage collection is started (manually or automatic)
    session_lifetime: 3600 # Number of seconds after which idle sessions should be garbage collected
    read_capacity: 10 # Default read capacity
    write_capacity: 10 # Default write capacity
    aws:
        region: us-east-1 # AWS Region to use
        version: latest # AWS API version
        credentials:
            key: AKA123456789 # Your AWS key
            secret: abcdeffhij # Your AWS secret

如果您使用 AWS IAM 角色,并且您的实例权限允许访问适当的 DynamoDb 表,则可以省略凭据。

如果表不存在,该包会为您创建具有指定容量的表。一旦表创建完成,容量配置值就不再使用(除非删除表)。

常见问题解答

修复 cURL 错误 #77

某些版本的 CentOS AWS AMI 可能需要此额外的 php.ini 配置来修复此异常

curl.cainfo="/etc/ssl/certs/ca-bundle.crt" 

来源:http://stackoverflow.com/a/26269489

许可证

MIT,见 LICENSE