PHPackages                             drbiko/dynamodb-sessions-dependency-free - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. drbiko/dynamodb-sessions-dependency-free

ActiveLibrary

drbiko/dynamodb-sessions-dependency-free
========================================

An implementation of a session handler for storing sessions in AWS's DynamoDB, but with no dependencies on the AWS SDK, Guzzle etc

v1.0.3(3y ago)01.8k1Apache-2.0PHPPHP &gt;=5.5

Since May 19Pushed 3y agoCompare

[ Source](https://github.com/drbiko/dynamodb-sessions-dependency-free)[ Packagist](https://packagist.org/packages/drbiko/dynamodb-sessions-dependency-free)[ Docs](https://github.com/drbiko/dynamodb-sessions-dependency-free)[ RSS](/packages/drbiko-dynamodb-sessions-dependency-free/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (4)Versions (6)Used By (0)

[ ![Idealstack - the best way to run PHP on AWS](https://camo.githubusercontent.com/fd73c6b2748a14f57f7061996bbdfb4b8adbd2aaa29c20c601ee7f5d87c14272/68747470733a2f2f696465616c737461636b2e696f2f6170706c69636174696f6e2f7468656d65732f696465616c737461636b2f696d672f6769746875622d62616e6e65722e737667 "Idealstack - the best way to run PHP on AWS")](https://idealstack.io/)dynamodb-sessions-dependency-free
=================================

[](#dynamodb-sessions-dependency-free)

[![](https://camo.githubusercontent.com/2ca5c8c1667a2524180c340bf8b9408d9be04dac1ff4a81a13417934c15eef50/68747470733a2f2f636f64656275696c642e75732d776573742d322e616d617a6f6e6177732e636f6d2f6261646765733f757569643d65794a6c626d4e79655842305a57524559585268496a6f69566a5253523038724f584e7561324979655755775a445650656d6b334d554e6a633039454d55673161574a6c546d52344d4374764e555a4f547a4e5662584a6e625870784e31566f544556315169747561474e4a536c677962546c684f454a7365474a5a53474e6c5a566f35546b46455231707250534973496d6c32554746795957316c644756795533426c59794936496b356a6433706d5a553168636c497a566d7833563349694c434a745958526c636d6c6862464e6c64464e6c636d6c68624349364d5830253344266272616e63683d6d6173746572)](https://camo.githubusercontent.com/2ca5c8c1667a2524180c340bf8b9408d9be04dac1ff4a81a13417934c15eef50/68747470733a2f2f636f64656275696c642e75732d776573742d322e616d617a6f6e6177732e636f6d2f6261646765733f757569643d65794a6c626d4e79655842305a57524559585268496a6f69566a5253523038724f584e7561324979655755775a445650656d6b334d554e6a633039454d55673161574a6c546d52344d4374764e555a4f547a4e5662584a6e625870784e31566f544556315169747561474e4a536c677962546c684f454a7365474a5a53474e6c5a566f35546b46455231707250534973496d6c32554746795957316c644756795533426c59794936496b356a6433706d5a553168636c497a566d7833563349694c434a745958526c636d6c6862464e6c64464e6c636d6c68624349364d5830253344266272616e63683d6d6173746572)

An implementation of a session handler for storing sessions in dynamoDB, but with no dependencies on the AWS SDK, Guzzle etc. As a bonus it's also faster!

The [Idealstack](https://idealstack.io) AWS hosting platform uses this to provide transparent support for DynamoDB sessions, so users don't need to change anything in their code.

See our [blog post](https://idealstack.io/blog/faster-dependency-free-php-sessions-dynamodb) about it for instructions on how to use it, setup the required tables etc

Features
========

[](#features)

- Essentially a drop-in replacement for the official session handler in the AWS SDK
- Dependency-free - does not depend on any other composer packages. Only requires the core curl and json extensions be enabled in PHP
- Does not require an autoloader (although will work fine with one, eg composer)
- Supports most common AWS authentication methods (eg instance profiles, ECS task roles, .aws config files, environment variables)
- Compatible with all major PHP versions (even PHP 5.6, for all you luddites out there)
- **Does not support locking** (that's just because we don't need it, a PR is welcome or raise an issue if you need it)

Why do you want this?
=====================

[](#why-do-you-want-this)

Possibly you don't. The [AWS SDK includes a session handler](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/service_dynamodb-session-handler.html) that is maintained by AWS and might be a better choice for most people.

Why do you want to store sessions in dynamodb? If you are running PHP in a clustered environment the default file-based session handler won't work.

You can store sessions in an SQL database, or Redis, but in many ways dynamodb is a better choice on AWS. It automatically scales to any number of reads/writes, can be distributed globally, has an elastic pricing model that is cheaper for small sites etc etc.

Here's a couple of reasons why you might want to use this code over the AWS SDK:

- If you aren't using the AWS SDK for other things, the session handler is going to include a large number of PHP classes on every page load that aren't needed. This potentially slows things down, uses more RAM, IO and Opcache etc
- It's faster. About 30% faster. We're talking about the difference between 30ms and 20ms here, so it's unlikely that sessions are the bottleneck slowing your app down. Still, faster is always good.
- If you choose to include this automatically using php's auto\_prepend\_file - you can get funny side-effects if you use the AWS SDK version. It requires an autoloader, which can mess with your project's own autoloading. Also it 'pollutes' the namespace. If your code uses a different version of the SDK from the one the sessions use, you should expect problems. This is the reason why we developed this for [Idealstack](https://idealstack.io) as we make dynamodb sessions transparent to our users code.

Installation
============

[](#installation)

via composer

`composer require idealstack/dynamodb-sessions-dependency-free`

or clone this repository

How to use it
=============

[](#how-to-use-it)

Configuration is the same as the AWS SDK version, so read their docs:

[https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/service\_dynamodb-session-handler.html](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/service_dynamodb-session-handler.html)

You configure the DynamoDB table the same as the AWS SDK docs recommend. However we'd suggest you also use the DynamoDB 'ttl' capability to garbage collect your sessions. Set that on the 'expires' field (this also works with the native SDK). See the [notes in our blog post](https://idealstack.io/blog/faster-dependency-free-php-sessions-dynamodb) about how to setup the table.

```
use Idealstack\DynamoDbSessionHandlerDependencyFree;
// or if you don't want to use composer auto-loader, try:
// require(__DIR__ .'/vendor/idealstack/dynamodb-session-handler-dependency-free/src/DynamoDbSessionHandler.php');

(new Idealstack\DynamoDbSessionsDependencyFree\DynamoDbSessionHandler(
[
            'table_name' => 'your-session-table-name',
            'region'     => 'local',
            'endpoint'   => 'http://localhost:8000',
// Credentials.  In production we recomend you use an instance role so you do not need to hardcode these.
// At least make sure you don't hardcode them and commit them to github!
            'credentials' => [
                'key' => 'AAAAAAAAAAAAAAAAAAAAAA',
                'secret' => 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'
            ],
// These are all defaults.
//             // Base64 encode data when reading and writing. Avoids problems with binary data,  Note this is
//             // not the behaviour of the AWS SDK, so set to false if you require compatibility with existing
//             // sessions  created with the SDK
//            'base64' => true,
//            'hash_key' => 'id',
//
//            // The lifetime of an inactive session before it should be garbage collected. If it isn't provided,
//            // the actual lifetime value that will be used is ini_get('session.gc_maxlifetime').
//            'session_lifetime' => 86400, // 24 hours
//            'consistent_reads' => true, //You almost certainly want this to be true
//            'session_locking' => false, //True is not supported
        ]

))->register();
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~420 days

Total

4

Last Release

1288d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/48100596?v=4)[Biko Allen](/maintainers/drbiko)[@drbiko](https://github.com/drbiko)

---

Top Contributors

[![jonathonsim](https://avatars.githubusercontent.com/u/883073?v=4)](https://github.com/jonathonsim "jonathonsim (34 commits)")[![drbiko](https://avatars.githubusercontent.com/u/48100596?v=4)](https://github.com/drbiko "drbiko (4 commits)")[![dhdean](https://avatars.githubusercontent.com/u/7011123?v=4)](https://github.com/dhdean "dhdean (2 commits)")

---

Tags

amazonsdkawsdynamodbcloudsessions

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/drbiko-dynamodb-sessions-dependency-free/health.svg)

```
[![Health](https://phpackages.com/badges/drbiko-dynamodb-sessions-dependency-free/health.svg)](https://phpackages.com/packages/drbiko-dynamodb-sessions-dependency-free)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k511.3M2.2k](/packages/aws-aws-sdk-php)[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[aws/aws-sdk-php-resources

A resource-oriented API for interacting with AWS services

1381.8M10](/packages/aws-aws-sdk-php-resources)[aws/aws-php-sns-message-validator

Amazon SNS message validation for PHP

21421.5M91](/packages/aws-aws-php-sns-message-validator)[fedemotta/yii2-aws-sdk

This extension provides the AWS SDK integration for the Yii2 framework

15430.4k2](/packages/fedemotta-yii2-aws-sdk)[platinumpixs/aws-symfony2-bundle

A simple Symfony 2 bundle for including the AWS SDK for PHP.

1274.3k1](/packages/platinumpixs-aws-symfony2-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
