PHPackages                             semitexa/ledger - 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. semitexa/ledger

ActiveSemitexa-module[Database &amp; ORM](/categories/database)

semitexa/ledger
===============

Semitexa Ledger — SQLite append-only event ledger with NATS JetStream multi-node propagation

2026.06.21.0352(1mo ago)0422MITPHP ^8.4

Since Apr 10Compare

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

READMEChangelogDependencies (4)Versions (11)Used By (2)

Semitexa Ledger
===============

[](#semitexa-ledger)

`semitexa/ledger` adds an append-only SQLite event ledger with NATS-based cross-node propagation.

The package is opt-in at runtime. Keeping it installed in `semitexa/ultimate` no longer forces every app to provide ledger infrastructure immediately.

Enable It
---------

[](#enable-it)

Set these environment variables when you want the ledger to boot:

```
LEDGER_ENABLED=1
LEDGER_NODE_ID=store-a
LEDGER_HMAC_KEY=change-me
NATS_PRIMARY_URL=nats://nats:4222
```

Optional:

```
LEDGER_DB_PATH=/var/lib/semitexa/ledger/store-a.sqlite
LEDGER_DB_CONNECTION=default
NATS_SECONDARY_URL=nats://secondary:4222
EVENTS_DUAL_PRIMARY=nats
EVENTS_DUAL_SECONDARY=
```

Propagate Events
----------------

[](#propagate-events)

Mark an event with `#[Propagated]` to persist it in the local ledger and publish it to other nodes.

```
use Semitexa\Core\Attribute\AsEvent;
use Semitexa\Ledger\Attribute\Propagated;

#[AsEvent]
#[Propagated(domain: 'inventory')]
final class StockAdjusted
{
    private string $productId;
    private int $delta;

    public function getProductId(): string { return $this->productId; }
    public function getDelta(): int { return $this->delta; }
}
```

Getter/setter DTOs are supported. Ledger payload serialization uses the same getter convention as the core `PayloadSerializer`.

Enforce Aggregate Ownership
---------------------------

[](#enforce-aggregate-ownership)

Use `#[OwnedAggregate]` on propagated events and `#[AsAggregateCommand]` on commands that must execute on the owner node.

```
use Semitexa\Ledger\Attribute\AsAggregateCommand;
use Semitexa\Ledger\Attribute\OwnedAggregate;
use Semitexa\Ledger\Attribute\Propagated;

#[Propagated(domain: 'inventory')]
#[OwnedAggregate(type: 'product', idField: 'product_id', creates: true)]
final class ProductCreated {}

#[AsAggregateCommand(aggregateType: 'product', aggregateIdField: 'product_id')]
final readonly class UpdateProductPrice
{
    public function __construct(
        public string $product_id,
        public float $new_price,
    ) {}
}
```

Replay Remote Events
--------------------

[](#replay-remote-events)

Register an idempotent replay handler for events that must update the local main database.

```
use Semitexa\Ledger\Attribute\AsReplayHandler;
use Semitexa\Ledger\Domain\Contract\ReplayHandlerInterface;
use Semitexa\Ledger\Dto\LedgerEvent;

#[AsReplayHandler(domain: 'inventory', eventType: 'stock_adjusted')]
final class StockAdjustedReplayHandler implements ReplayHandlerInterface
{
    public function apply(LedgerEvent $event): void
    {
        // Update local projections idempotently using $event->eventId.
    }
}
```

Current Example In This Repo
----------------------------

[](#current-example-in-this-repo)

`packages/semitexa-demo/src/Application/Payload/Event/DemoItemCreated.php` and `DemoNotificationEvent.php` are marked with `#[Propagated(domain: 'demo')]` as the first live integration inside this workspace.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance93

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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 ~9 days

Recently: every ~16 days

Total

9

Last Release

34d ago

Major Versions

v0.0.2 → 2026.05.08.16402026-05-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/e94044da9f4c76cc5cd09ef0c693a68065787e10d0d18edfeedbef3573a9163a?d=identicon)[syntaxwanderer](/maintainers/syntaxwanderer)

---

Tags

sqliteevent sourcingjetstreamnatsledgersemitexa

### Embed Badge

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

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M7.0k](/packages/doctrine-dbal)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58925.9M54](/packages/scienta-doctrine-json-functions)[nette/caching

⏱ Nette Caching: library with easy-to-use API and many cache backends.

43719.3M405](/packages/nette-caching)[nette/database

💾 Nette Database: layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.

5687.0M263](/packages/nette-database)[nettrine/dbal

Doctrine DBAL for Nette Framework

332.7M24](/packages/nettrine-dbal)[goodway/laravel-nats

Nats jetstream queue driver with client for Laravel

356.0k](/packages/goodway-laravel-nats)

PHPackages © 2026

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