PHPackages                             lendable/aggregate - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lendable/aggregate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lendable/aggregate
==================

Lendable Aggregate Library

1.1.4(1y ago)2118.8k—1.5%1[5 PRs](https://github.com/Lendable/aggregate/pulls)MITPHPPHP ^8.2CI passing

Since Jun 2Pushed 1mo ago43 watchersCompare

[ Source](https://github.com/Lendable/aggregate)[ Packagist](https://packagist.org/packages/lendable/aggregate)[ RSS](/packages/lendable-aggregate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (24)Used By (0)

Lendable Aggregate
==================

[](#lendable-aggregate)

[![Latest Stable Version](https://camo.githubusercontent.com/016442373c571021e110f364f7c524c499d407a5817ef3e6f4df17628953c6da/68747470733a2f2f706f7365722e707567782e6f72672f6c656e6461626c652f6167677265676174652f762f737461626c65)](https://packagist.org/packages/lendable/aggregate)[![License](https://camo.githubusercontent.com/1e993ec935e2518400d1acb15c2695278cc7b43e80f539b2662fbcb6c7fede13/68747470733a2f2f706f7365722e707567782e6f72672f6c656e6461626c652f6167677265676174652f6c6963656e7365)](https://packagist.org/packages/lendable/aggregate)

Library with supporting functionality to bridge domain and infrastructure interactions for aggregates within event sourcing systems.

This does not help with building out your domain. Rather, it provides interfaces and base functionality for an infrastructure layer to interact with your aggregate classes without requiring them to implement library specific interfaces.

Installation
------------

[](#installation)

You can install the library via [Composer](https://getcomposer.org/).

```
composer require lendable/aggregate
```

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

[](#requirements)

- PHP &gt;= 8.2

Functionality
-------------

[](#functionality)

### `AggregateIdExtractor`

[](#aggregateidextractor)

Defines a contract for extracting an `AggregateId` from domain aggregate objects. Your aggregate class should not hold an `AggregateId` instance, but instead a domain specific identifier type (e.g. `UserId`).

### `AggregateTypeResolver`

[](#aggregatetyperesolver)

Defines a contract for resolving an `AggregateType` from domain aggregate objects. An `AggregateType` is a classification of aggregate. This is an infrastructure concern, and is aimed towards audit logging alongside an `AggregateId` and single schema / multiple aggregate storage patterns.

### `AggregateVersionExtractor`

[](#aggregateversionextractor)

Defines a contract for extracting an `AggregateVersion` from domain aggregate objects. This is an event sourcing infrastructure concept whereby (usually) the version increases for each event that has taken place to influence the state of the aggregate.

Testing support
---------------

[](#testing-support)

The `AggregateIdExtractorSpec`, `AggregateTypeResolverSpec` and `AggregateVersionExtractorSpec` are provided to ease testing of your implementations. Simply extend these classes for your own test suite and implement the hook points.

```
use Lendable\Aggregate\Testing\AggregateIdExtractorSpec;
use Lendable\Aggregate\AggregateIdExtractor;
use Lendable\Aggregate\AggregateId;

final class FooIdExtractor extends AggregateIdExtractorSpec
{
    protected function createExtractor(): AggregateIdExtractor
    {
        return new FooIdExtractor();
    }

    protected function createExpectedAggregateId(): AggregateId
    {
        return AggregateId::fromString('1406fd13-29d3-44e3-812c-c1cd14e12b38');
    }

    protected function createAggregateWithExpectedAggregateId(): object
    {
        return Foo::register(FooId::fromString('1406fd13-29d3-44e3-812c-c1cd14e12b38'));
    }
}
```

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance66

Regular maintenance activity

Popularity35

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 67.6% 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 ~125 days

Recently: every ~100 days

Total

11

Last Release

554d ago

Major Versions

0.4.0 → 1.0.02023-10-06

PHP version history (4 changes)0.1.0PHP &gt;=7.4.0

0.3.0PHP &gt;=8.0.0

1.0.0PHP &gt;=8.1.0

1.1.3PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/893f1dc6753940f80d1fe2e9a90db68961bb7f16eab85d6a868e7aecccf8de13?d=identicon)[ben-challis](/maintainers/ben-challis)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (564 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (158 commits)")[![ben-challis](https://avatars.githubusercontent.com/u/8275163?v=4)](https://github.com/ben-challis "ben-challis (86 commits)")[![marmichalski](https://avatars.githubusercontent.com/u/57528542?v=4)](https://github.com/marmichalski "marmichalski (17 commits)")[![mdjward](https://avatars.githubusercontent.com/u/4046455?v=4)](https://github.com/mdjward "mdjward (3 commits)")[![mannion007](https://avatars.githubusercontent.com/u/5822816?v=4)](https://github.com/mannion007 "mannion007 (2 commits)")[![AlexisColes](https://avatars.githubusercontent.com/u/8488871?v=4)](https://github.com/AlexisColes "AlexisColes (1 commits)")[![martin-georgiev](https://avatars.githubusercontent.com/u/4849482?v=4)](https://github.com/martin-georgiev "martin-georgiev (1 commits)")[![mateuszsip](https://avatars.githubusercontent.com/u/1377075?v=4)](https://github.com/mateuszsip "mateuszsip (1 commits)")[![lendabot[bot]](https://avatars.githubusercontent.com/u/10513749?v=4)](https://github.com/lendabot[bot] "lendabot[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[pocketmine/pocketmine-mp

A server software for Minecraft: Bedrock Edition written in PHP

3.5k74.6k86](/packages/pocketmine-pocketmine-mp)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[getdkan/dkan

DKAN Open Data Catalog

385135.4k2](/packages/getdkan-dkan)[firefly-iii/data-importer

Firefly III Data Import Tool.

7545.8k](/packages/firefly-iii-data-importer)[tomaj/hermes

Simple php background processing library

38251.0k5](/packages/tomaj-hermes)

PHPackages © 2026

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