PHPackages                             phpgears/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. phpgears/aggregate

ActiveLibrary

phpgears/aggregate
==================

Aggregate base

0.2.1(6y ago)0242MITPHPPHP ^7.1CI failing

Since Dec 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/phpgears/aggregate)[ Packagist](https://packagist.org/packages/phpgears/aggregate)[ Docs](https://github.com/phpgears/aggregate)[ RSS](/packages/phpgears-aggregate/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (18)Versions (9)Used By (0)

[![PHP version](https://camo.githubusercontent.com/d0b5687c6812c5d52d86a548e09db527eeb7860f82adbb677de00a36ddbed1b4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344372e312d3838393242462e7376673f7374796c653d666c61742d737175617265)](http://php.net)[![Latest Version](https://camo.githubusercontent.com/646d8aff956a7eed0cbe64d8e9da82ab99b886a3c346e862d21f3206c1e638cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70687067656172732f6167677265676174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpgears/aggregate)[![License](https://camo.githubusercontent.com/0ba4125fc118d58e5ecaa67e82709604cf2588efc1fc2d39498c2d3feb9e513d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70687067656172732f6167677265676174652e7376673f7374796c653d666c61742d737175617265)](https://github.com/phpgears/aggregate/blob/master/LICENSE)

[![Build Status](https://camo.githubusercontent.com/365cae6fd45e235e5ade93dcaf63cf5872b101fb979a8cc507e5980441e0831c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f70687067656172732f6167677265676174652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/phpgears/aggregate)[![Style Check](https://camo.githubusercontent.com/8485ae01aa8cbe14a762674b33261bf0437b2cff31f08a9b00e5721e2439796e/68747470733a2f2f7374796c6563692e696f2f7265706f732f3134393033373532302f736869656c64)](https://styleci.io/repos/149037520)[![Code Quality](https://camo.githubusercontent.com/d8d15c9af5f91f0c4ac7a144300118d6d20fc18765134d65df2d0f38355fbd88/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f70687067656172732f6167677265676174652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/phpgears/aggregate)[![Code Coverage](https://camo.githubusercontent.com/130b0cb3f7f989e5846568dc5a8b458386b726d6777b118ec0a7c51e14c42540/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f70687067656172732f6167677265676174652e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/phpgears/aggregate)

[![Total Downloads](https://camo.githubusercontent.com/d602d8dad5e4c769147e236bc13f284b9161bb8c7994ae62df214894e57f75be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70687067656172732f6167677265676174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpgears/aggregate/stats)[![Monthly Downloads](https://camo.githubusercontent.com/48c7b3fe4cbfe4cd6c8594234898a28830e75628a9ea8a5703f89f8fb1fcfaad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f70687067656172732f6167677265676174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpgears/aggregate/stats)

Aggregate
=========

[](#aggregate)

Aggregate base

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

[](#installation)

### Composer

[](#composer)

```
composer require phpgears/aggregate

```

Usage
-----

[](#usage)

Require composer autoload file

```
require './vendor/autoload.php';
```

### Aggregate identity

[](#aggregate-identity)

Aggregate identities are provided by [gears/identity](https://github.com/phpgears/identity), head over there to learn about them

### Aggregate root

[](#aggregate-root)

Aggregate roots should implement `Gears\Aggregate\AggregateRoot` interface. You can extend from `Gears\Aggregate\AbstractAggregateRoot` for simplicity

```
use Gears\Aggregate\AbstractAggregateRoot;
use Gears\Identity\Identity;

class CustomAggregate extends AbstractAggregateRoot
{
    public static function instantiate(Identity $identity): self
    {
        return new self($identity);
    }
}
```

Mind that AbstractAggregateRoot constructor is protected forcing you to create static named constructors methods

#### Entities

[](#entities)

Entities can implement `Gears\Aggregate\Entity` interface. You can extend from `Gears\Aggregate\AbstractEntity` for simplicity

#### Events

[](#events)

Aggregate roots can record [gears/event](https://github.com/phpgears/event) as operations are performed

```
use Gears\Aggregate\AbstractAggregateRoot;
use Gears\Identity\Identity;

class CustomAggregate extends AbstractAggregateRoot
{
    public static function instantiate(Identity $identity): self
    {
        return new self($identity);
    }

    public function doSomething(): void
    {
        // do something

        $this->recordEvent(new SomethingHappened());
    }
}
```

These events could be collected afterwards and sent to an event bus such as [gears/event](https://github.com/phpgears/event)

```
$customAggregate = CustomAggregate::instantiate(
    UuidIdentity::fromString('4c4316cb-b48b-44fb-a034-90d789966bac')
);
$customAggregate->doSomething();

foreach ($customAggregate->collectRecordedEvents() as $event) {
    /** @var \Gears\Event\EventBus $eventBus */
    $eventBus->dispatch($event);
}
```

Contributing
------------

[](#contributing)

Found a bug or have a feature request? [Please open a new issue](https://github.com/phpgears/aggregate/issues). Have a look at existing issues before.

See file [CONTRIBUTING.md](https://github.com/phpgears/aggregate/blob/master/CONTRIBUTING.md)

License
-------

[](#license)

See file [LICENSE](https://github.com/phpgears/aggregate/blob/master/LICENSE) included with the source code for a copy of the license terms.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Recently: every ~66 days

Total

7

Last Release

2393d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c50421f1ab4148354dc2dd5dcaba168656b17ea913b310d112deb39a6f73ca1?d=identicon)[juliangut](/maintainers/juliangut)

---

Top Contributors

[![juliangut](https://avatars.githubusercontent.com/u/1104131?v=4)](https://github.com/juliangut "juliangut (18 commits)")

---

Tags

immutableaggregate

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[aeon-php/calendar

PHP type safe, immutable calendar library

2079.7M16](/packages/aeon-php-calendar)[darsyn/ip

An immutable IP Address value object that provides several different notations, including helper functions.

2572.0M20](/packages/darsyn-ip)[qaribou/immutable.php

Immutable, highly-performant collections, well-suited for functional programming and memory-intensive applications.

344146.0k](/packages/qaribou-immutablephp)[innmind/immutable

Immutable PHP primitive wrappers

75218.0k74](/packages/innmind-immutable)[vasek-purchart/doctrine-date-time-immutable-types

Doctrine DateTimeImmutable types

42228.3k](/packages/vasek-purchart-doctrine-date-time-immutable-types)[rtlopez/decimal

An object oriented immutable arbitrary-precision arithmetic library for PHP

27262.8k2](/packages/rtlopez-decimal)

PHPackages © 2026

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