PHPackages                             dynamite/dynamite - 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. dynamite/dynamite

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

dynamite/dynamite
=================

PHP DynamoDB Mapper

v0.0.7(1y ago)32.1k2[2 issues](https://github.com/dynamitephp/dynamite/issues)1MITPHPPHP &gt;= 8 | 8.1CI failing

Since Jan 9Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/dynamitephp/dynamite)[ Packagist](https://packagist.org/packages/dynamite/dynamite)[ RSS](/packages/dynamite-dynamite/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (7)Dependencies (5)Versions (9)Used By (1)

dynamite/dynamite
=================

[](#dynamitedynamite)

[![FOSSA Status](https://camo.githubusercontent.com/1de68f8f0c70e68b5750b93a8b363ca231475869707096282d660750988ee300/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d25324670697a7a616d696e64656425324664796e616d6974652e7376673f747970653d736869656c64)](https://app.fossa.com/projects/git%2Bgithub.com%2Fpizzaminded%2Fdynamite?ref=badge_shield)

Work with AWS DynamoDB and Single-Table-Designed tables in your apps.

Requires `aws/aws-sdk-php` with `3.*` version.

Getting started
---------------

[](#getting-started)

### Installation

[](#installation)

`composer require dynamite/dynamite`

### Configuration

[](#configuration)

Some important things you need to know:
---------------------------------------

[](#some-important-things-you-need-to-know)

### Your table schema

[](#your-table-schema)

- Dynamite assumes that there is a table with partition key and sort key created.
- When developing locally, use [DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html).
- Dynamite assumes that tables/indexes are created and active.

### You need to bring your own ID Generator

[](#you-need-to-bring-your-own-id-generator)

See `docs/bring-your-own-id.md` for more information.

The unordered roadmap to `v1.0.0`
---------------------------------

[](#the-unordered-roadmap-to-v100)

- Creating an item
- Document how to create an item
- Storing an item
- Document how to store an item
- Getting item
- Document how to get an item
- `ItemRepository`
- Access Pattern Operations
- Bulk operations
- Condition Expressions
- Unit of Work
- Support for all operations in `SingleTableService`
- `DynamiteRegistry` to work with more than one table
- Psalm pipeline must be green
- PHPUnit coverage &gt; 90%
- Support for PHP8 Attributes
- `@DuplicateTo` annotation - duplicate some attributes to additional items while putting them to DynamoDB
- Some Console commands for Items mapping validation and project maintenance

Documentation
-------------

[](#documentation)

### Item Duplication

[](#item-duplication)

**Item duplication requires `dynamodb:BatchWriteItem` enabled.**

When you need to duplicate an object to many items at once, you can use `@DuplicateTo` annotation:

```
/**
 * @Dynamite\Item(objectType="USER")
 * @Dynamite\PartitionKeyFormat("USER#{id}")
 * @Dynamite\SortKeyFormat("USER")
 * @Dynamite\DuplicateTo(pk="UDATA#{email}", sk="UDATA", props={"id", "username"})
 * @Dynamite\DuplicateTo(pk="UDATA#{username}", sk="UDATA", props={"id", "email"})
*/
class User {
    //...props
}

$user = new User('123', 'user@example.com', 'mickey')

```

In this case, There will be 3 items sent to DynamoDB:

- PK: `USER#123` SK:`USER` with **all** attributes defined in item;
- PK: `UDATA#user@example` SK: `UDATA` with `id` and `username` props;
- PK: `UDATA#mickey` SK: `UDATA` with `id` and `email` props.

You can add a `transform` param to annotation to fill Primary key pair with lowercased/uppercased params:

```

//In this case PK: UDATA#MICKEY
@Dynamite\DuplicateTo(pk="UDATA#{username}", sk="UDATA", props={"id", "email"}, transform="UPPER")

//In this case PK: UDATA#mickey
@Dynamite\DuplicateTo(pk="UDATA#{username}", sk="UDATA", props={"id", "email"}, transform="LOWER")

```

By default params are passed as-is. `transform` works only for params injected to key, key template remains untouched.

### Creating an Item

[](#creating-an-item)

@TODO

### Annotations

[](#annotations)

Dynamite uses `doctrine/annotation` under the hood to parse all item annotations to provide `doctrine/orm`-like mapping configuration.

#### PrimaryKeyFormat and SortKeyFormat

[](#primarykeyformat-and-sortkeyformat)

Allows you to define the format of primary key pair of Item stored in table.

**When Partition Key or Sort Key will be passed to build Partition Key or Sort Key, Dynamite will break.**

```
/**
 * Use class properties from your object wrapped with {} as a placeholders for values.
 * Warning: {itemType} will be taken from @ItemType annotation.
 * @Item(objectType="USER")
 * @PartitionKeyFormat('{itemType}#{username}')
 * @SortKeyFormat('{itemType}')
 */
class User {

    public $email;

    public $username;

}

$user = new User();
$user->username = 'tonystark';
//In this example, object will be stored with "USER#tonystark" PK and "USER" Sort key

```

### Nested items

[](#nested-items)

Nested item is... an item nested in another item. It cannot have a Partition Key as it would be taken from parent (or first non-nested item when multiple nested) object.

Nested item cannot have both `@Item` and `@NestedItem` annotation.

Ideas for future:
-----------------

[](#ideas-for-future)

- `NestedValueObjectAttribute#type should not be required when property is defined`

License
-------

[](#license)

MIT

[![FOSSA Status](https://camo.githubusercontent.com/7d8b7ad9a05824ec73257efaca849e529bbda53ecdfeda8a46d69f3cecace47e/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d25324670697a7a616d696e64656425324664796e616d6974652e7376673f747970653d6c61726765)](https://app.fossa.com/projects/git%2Bgithub.com%2Fpizzaminded%2Fdynamite?ref=badge_large)

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance55

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.1% 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 ~255 days

Recently: every ~366 days

Total

7

Last Release

468d ago

PHP version history (2 changes)v0.0.3PHP &gt;= 7.4

v0.0.4PHP &gt;= 8 | 8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13077797?v=4)[Mikolaj Czajkowski](/maintainers/pizzaminded)[@pizzaminded](https://github.com/pizzaminded)

---

Top Contributors

[![pizzaminded](https://avatars.githubusercontent.com/u/13077797?v=4)](https://github.com/pizzaminded "pizzaminded (217 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (1 commits)")[![fossabot](https://avatars.githubusercontent.com/u/29791463?v=4)](https://github.com/fossabot "fossabot (1 commits)")

---

Tags

awsaws-dynamodbdynamodbphpphp7php74php80php81

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

10.2k3.5k](/packages/leantime-leantime)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[keboola/storage-api-client

Keboola Storage API PHP Client

10405.9k39](/packages/keboola-storage-api-client)

PHPackages © 2026

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