PHPackages                             bemit/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. [Database &amp; ORM](/categories/database)
4. /
5. bemit/dynamodb

ActiveLibrary[Database &amp; ORM](/categories/database)

bemit/dynamodb
==============

Custom PHP service class for DynamoDB, with item-data converters

0.0.2(4y ago)0281MITPHPPHP &gt;=8.1

Since Nov 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/bemit/php-service-dynamodb)[ Packagist](https://packagist.org/packages/bemit/dynamodb)[ RSS](/packages/bemit-dynamodb/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

PHP DynamoDB Service
====================

[](#php-dynamodb-service)

[![Latest Stable Version](https://camo.githubusercontent.com/c8389fa192ea29b6c8f793701aab24001001d6a739ff37ae7fbd8c844033987b/68747470733a2f2f706f7365722e707567782e6f72672f62656d69742f64796e616d6f64622f76657273696f6e2e737667)](https://packagist.org/packages/bemit/dynamodb)[![Latest Unstable Version](https://camo.githubusercontent.com/db539f73aa30ff7449acdd2f40c348adadfcfaeecc388362d94d2d413fd8895f/68747470733a2f2f706f7365722e707567782e6f72672f62656d69742f64796e616d6f64622f762f756e737461626c652e737667)](https://packagist.org/packages/bemit/dynamodb)[![codecov](https://camo.githubusercontent.com/3c258082a363a4fe9a641012fea8e9ca65e26583038395fa9bbdf0f258802d49/68747470733a2f2f636f6465636f762e696f2f67682f62656d69742f7068702d736572766963652d64796e616d6f64622f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4438304d443353523751)](https://codecov.io/gh/bemit/php-service-dynamodb)[![Total Downloads](https://camo.githubusercontent.com/b9b1ee5c20df2cc8a787be0e63f28dc00ed59bc448c80f89024f8079b6c440bf/68747470733a2f2f706f7365722e707567782e6f72672f62656d69742f64796e616d6f64622f646f776e6c6f6164732e737667)](https://packagist.org/packages/bemit/dynamodb)[![Github actions Build](https://github.com/bemit/php-service-dynamodb/actions/workflows/blank.yml/badge.svg)](https://github.com/bemit/php-service-dynamodb/actions)[![PHP Version Require](https://camo.githubusercontent.com/c682a8870517af1c69dd2a096a244d22e1eff9cc3a336162135b0cc56455e774/687474703a2f2f706f7365722e707567782e6f72672f62656d69742f64796e616d6f64622f726571756972652f706870)](https://packagist.org/packages/bemit/dynamodb)

PHP DynamoDB service class, with item &lt;&gt; data converters.

```
composer require bemit/dynamodb
```

Usage:

```
use Bemit\DynamoDB\DynamoService;

$service = new DynamoService(
    string $region,
    string $dynamo_key, string $dynamo_secret,
    ?string $endpoint = null,
    $debug = false,
    // optional, overwrite the converters:
    ConvertFromItemInterface $from_item = null,
    ConvertToItemInterface $to_item = null,
);

// just the dynamodb client:
$client = $service->client();

//
// Convert from array / stdClass to DynamoDB Item:

// $arr = ['some_key' => 'the-text']
$item = $service->toItem($arr);

// or as stdClass:
// $std = new stdClass;
// $std->some_key = 'the-text';
$item = $service->toItem($std);

// single value:
// $arr_e = 'the-text'
$item_p = $service->toItemValue($arr_e);

//
// Convert from DynamoDB Item to array / stdClass:

// $item = ['some_key' => ['S' => 'the-text']]
$arr = $service->fromItem($item);
// $item_p = ['S' => 'the-text']]
$arr_p = $service->fromItemValue($item_p);

//
// Convert NS/SS from array / stdClass to DynamoDB:
//
// NS + SS needs a "key schema" when converting from array to item,
// nested usages of NS/SS are not automated and would result in a `L` the next save

// $arr_ss = ['s1', 's2', 's3']
$item_ss = $service->toItemValue($arr_ss, 'SS');
// $arr_ns = [1, 2, 3]
$item_ns = $service->toItemValue($arr_ns, 'NS');

// or:
// $obj = ['prop1' => ['s1', 's2', 's3']]
$item_obj = $service->toItem($obj, ['prop1' => 'SS']);

//
// Ignore Nulls using when converting from array / stdClass to DynamoDB

// `true` as  third parameter of `toItem` will ignore null values in the root level of the item
// $arr = ['k1' => 's1', 'k2' => null]
$item = $service->toItem($arr, [], true);
```

Modes supported, with automatic detection and conversion:

- `S`, strings
- `N`, numerics, cast by `(float)`, keeps numbers the same in e.g. JSON (no `.0`)
- `BOOL`, booleans
- `M`, maps, `stdClass` or assoc arrays
    - for safest usage uses `stdClass` for `M` conversion
    - for app-side, you should use e.g. non-assoc `json_decode`
    - supports nested maps &amp; lists
- `L`, lists / arrays **or empty array**
    - supports nested lists &amp; maps
- `NULL`, null values

Modes supported with typing at `toItem`, automatic at `fromItem`:

- `SS`, string sets / list of strings
- `NS`, string sets / list of strings

Dev Notices
-----------

[](#dev-notices)

Commands to set up and run e.g. tests:

```
# on windows:
docker run -it --rm -v %cd%:/app composer install --ignore-platform-reqs

docker run -it --rm -v %cd%:/var/www/html php:8.1-rc-cli-alpine sh

docker run --rm -v %cd%:/var/www/html php:8.1-rc-cli-alpine sh -c "cd /var/www/html && ./vendor/bin/phpunit --testdox -c phpunit-ci.xml"

#docker-compose run --rm test sh -c "cd /var/www/html && composer update"
docker-compose run --rm test sh

cd /var/www/html && ./vendor/bin/phpunit --coverage-text --testdox -c phpunit-ci.xml

cd /var/www/html && ./vendor/bin/phpunit --coverage-html coverage --testdox -c phpunit-ci.xml

# on unix:
docker run -it --rm -v `pwd`:/app composer install

docker run -it --rm -v `pwd`:/var/www/html php:8.1-rc-cli-alpine sh

docker run --rm -v `pwd`:/var/www/html php:8.1-rc-cli-alpine sh -c "cd /var/www/html && ./vendor/bin/phpunit --testdox -c phpunit-ci.xml"
```

Versions
--------

[](#versions)

This project adheres to [semver](https://semver.org/), **until `1.0.0`** and beginning with `0.1.0`: all `0.x.0` releases are like MAJOR releases and all `0.0.x` like MINOR or PATCH, modules below `0.1.0` should be considered experimental.

License
-------

[](#license)

This project is free software distributed under the [**MIT LICENSE**](LICENSE).

> Amazon DynamoDB® is a trademark of Amazon.com, Inc. No endorsements by Amazon.com, Inc. are implied by the use of these marks.

### Contributors

[](#contributors)

By committing your code to the code repository you agree to release the code under the MIT License attached to the repository.

---

Maintained by [Michael Becker](https://mlbr.xyz)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

1655d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/946489901a36f4507ead2ce24d3e9c6570ae4e16ab1aed0ef6314237302ecb37?d=identicon)[bemit](/maintainers/bemit)

---

Top Contributors

[![elbakerino](https://avatars.githubusercontent.com/u/7737034?v=4)](https://github.com/elbakerino "elbakerino (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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