PHPackages                             quankim/dynamodb - 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. quankim/dynamodb

ActiveLibrary

quankim/dynamodb
================

DynamoDb wrapper for your Laravel model and helpers =&gt; fork from https://github.com/baopham/laravel-dynamodb

0.79(9y ago)014MITPHP

Since Aug 4Pushed 9y agoCompare

[ Source](https://github.com/quanvhframgia/laravel-dynamodb)[ Packagist](https://packagist.org/packages/quankim/dynamodb)[ RSS](/packages/quankim-dynamodb/feed)WikiDiscussions master Synced 2mo ago

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

laravel-dynamodb
================

[](#laravel-dynamodb)

### Fork from https://github.com/baopham/laravel-dynamodb

[](#fork-from-httpsgithubcombaophamlaravel-dynamodb)

[![Latest Stable Version](https://camo.githubusercontent.com/8fbe86ae1b6f274d7efae9293dab388e6b078f82177cf60384cfa5b4d0f6fb01/68747470733a2f2f706f7365722e707567782e6f72672f62616f7068616d2f64796e616d6f64622f762f737461626c65)](https://packagist.org/packages/baopham/dynamodb)[![Total Downloads](https://camo.githubusercontent.com/1d75e034de9f69bcfd1816c091bc095a495c26ca0c21757cc4a850b0accaea4f/68747470733a2f2f706f7365722e707567782e6f72672f62616f7068616d2f64796e616d6f64622f646f776e6c6f616473)](https://packagist.org/packages/baopham/dynamodb)[![Latest Unstable Version](https://camo.githubusercontent.com/29d275ea5bc54a0d450a7943d5a749232f08c626f4dfcec5e7a513cc7bbe1154/68747470733a2f2f706f7365722e707567782e6f72672f62616f7068616d2f64796e616d6f64622f762f756e737461626c65)](https://packagist.org/packages/baopham/dynamodb)[![License](https://camo.githubusercontent.com/009b4a2ca8a011ae0b60c9aa2db2220b7060a31b8cb5497add740c3cd0c4ad92/68747470733a2f2f706f7365722e707567782e6f72672f62616f7068616d2f64796e616d6f64622f6c6963656e7365)](https://packagist.org/packages/baopham/dynamodb)

Supports all key types - primary hash key and composite keys.

> For advanced users only. If you're not familiar with Laravel, Laravel Eloquent and DynamoDB, then I suggest that you get familiar with those first.

> **Breaking Changes** for v0.4
>
> - If you're using v0.3 and below, please see [here](./README.v0.3.md)
> - To upgrade to v0.4, please see the [migration note]('./MIGRATION.md')

- [Install](#install)
- [Usage](#usage)
- [Indexes](#indexes)
- [Composite Keys](#composite-keys)
- [Test](#test)
- [Requirements](#requirements)
- [Todo](#todo)
- [License](#license)
- [Author and Contributors](#author-and-contributors)

Install
-------

[](#install)

- Composer install

    ```
    composer require baopham/dynamodb
    ```
- Install service provider:

    ```
    // config/app.php

    'providers' => [
        ...
        BaoPham\DynamoDb\DynamoDbServiceProvider::class,
        ...
    ];
    ```
- Put DynamoDb config in `config/aws.php`:

    ```
    // config/aws.php
    ...
    'credentials' => [
        'key'    => env('AWS_ACCESS_KEY_ID', ''),
        'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
    ],
    'region' => env('AWS_REGION', 'us-east-1'),
    'version' => 'latest',
    'endpoint' => env('AWS_ENDPOINT', ''),
    ...
    ```

Usage
-----

[](#usage)

- Extends your model with `BaoPham\DynamoDb\DynamoDbModel`, then you can use Eloquent methods that are supported. The idea here is that you can switch back to Eloquent without changing your queries.

Supported methods:

```
// find and delete
$model->find();
$model->delete();

// Using getIterator(). If 'key' is the primary key or a global/local index and the condition is EQ, will use 'Query', otherwise 'Scan'.
$model->where('key', 'key value')->get();

// See BaoPham\DynamoDb\ComparisonOperator
$model->where(['key' => 'key value']);
// Chainable for 'AND'. 'OR' is not supported.
$model->where('foo', 'bar')
    ->where('foo2', '!=' 'bar2')
    ->get();

// Using scan operator, not too reliable since DynamoDb will only give 1MB total of data.
$model->all();

// Basically a scan but with limit of 1 item.
$model->first();

// update
$model->update($attributes);

$model = new Model();
// Define fillable attributes in your Model class.
$model->fillableAttr1 = 'foo';
$model->fillableAttr2 = 'foo';
// DynamoDb doesn't support incremented Id, so you need to use UUID for the primary key.
$model->id = 'de305d54-75b4-431b-adb2-eb6b9e546014'
$model->save();

// chunk
$model->chunk(10, function ($records) {
    foreach ($records as $record) {

    }
});
```

- Or if you want to sync your DB table with a DynamoDb table, use trait `BaoPham\DynamoDb\ModelTrait`, it will call a `PutItem` after the model is saved.

Indexes
-------

[](#indexes)

If your table has indexes, make sure to declare them in your model class like so

```
/**
 * Indexes.
 * [
 *     'simple_index_name' => [
 *          'hash' => 'index_key'
 *     ],
 *     'composite_index_name' => [
 *          'hash' => 'index_hash_key',
 *          'range' => 'index_range_key'
 *     ],
 * ].
 *
 * @var array
 */
protected $dynamoDbIndexKeys = [
    'count_index' => [
        'hash' => 'count'
    ],
];
```

Note that order of index matters when a key exists in multiple indexes.
For example, we have this

```
$this->where('user_id', 123)->where('count', '>', 10)->get();
```

with

```
protected $dynamoDbIndexKeys = [
    'count_index' => [
        'hash' => 'user_id',
        'range' => 'count'
    ],
    'user_index' => [
        'hash' => 'user_id',
    ],
];
```

will use `count_index`.

```
protected $dynamoDbIndexKeys = [
    'user_index' => [
        'hash' => 'user_id',
    ],
    'count_index' => [
        'hash' => 'user_id',
        'range' => 'count'
    ]
];
```

will use `user_index`.

Composite Keys
--------------

[](#composite-keys)

To use composite keys with your model:

- Set `$compositeKey` to an array of the attributes names comprising the key, e.g.

```
protected $primaryKey = ['customer_id'];
protected $compositeKey = ['customer_id', 'agent_id'];
```

- To find a record with a composite key

```
$model->find(['id1' => 'value1', 'id2' => 'value2']);
```

Test
----

[](#test)

Run:

```
$ java -Djava.library.path=./DynamoDBLocal_lib -jar dynamodb_local/DynamoDBLocal.jar --port 3000
$ ./vendor/bin/phpunit
```

- DynamoDb local version: 2016-01-07\_1.0
- DynamoDb local schema for tests created by the [DynamoDb local shell](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.Shell.html) is located [here](dynamodb_local_schema.js)

Requirements
------------

[](#requirements)

Laravel ^5.1

TODO
----

[](#todo)

- Upgrade a few legacy attributes: `AttributesToGet`, `ScanFilter`, ...

License
-------

[](#license)

MIT

Author and Contributors
-----------------------

[](#author-and-contributors)

- [Bao Pham](https://github.com/baopham/laravel-dynamodb)
- [warrick-loyaltycorp](https://github.com/warrick-loyaltycorp)
- [Alexander Ward](https://github.com/cthos)
- [Quang Ngo](https://github.com/vanquang9387)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 67.7% 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 ~40 days

Recently: every ~12 days

Total

14

Last Release

3411d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13218211?v=4)[Mr.Don't Ask](/maintainers/quanvh)[@quanvh](https://github.com/quanvh)

---

Top Contributors

[![baopham](https://avatars.githubusercontent.com/u/783410?v=4)](https://github.com/baopham "baopham (65 commits)")[![vanquang9387](https://avatars.githubusercontent.com/u/7125810?v=4)](https://github.com/vanquang9387 "vanquang9387 (14 commits)")[![warrick-loyaltycorp](https://avatars.githubusercontent.com/u/16530482?v=4)](https://github.com/warrick-loyaltycorp "warrick-loyaltycorp (12 commits)")[![cthos](https://avatars.githubusercontent.com/u/456545?v=4)](https://github.com/cthos "cthos (4 commits)")[![xabbuh](https://avatars.githubusercontent.com/u/1957048?v=4)](https://github.com/xabbuh "xabbuh (1 commits)")

---

Tags

laravelawsdynamodb

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/quankim-dynamodb/health.svg)

```
[![Health](https://phpackages.com/badges/quankim-dynamodb/health.svg)](https://phpackages.com/packages/quankim-dynamodb)
```

###  Alternatives

[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)[baopham/dynamodb

Eloquent syntax for DynamoDB

4975.7M6](/packages/baopham-dynamodb)[oryxcloud/laravel-dynamodb-session-driver

DynamoDB Session Driver for Laravel 5

1460.8k](/packages/oryxcloud-laravel-dynamodb-session-driver)

PHPackages © 2026

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