PHPackages                             flux-eco/aggregate-root - 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. flux-eco/aggregate-root

ActiveFlux-app[Utility &amp; Helpers](/categories/utility)

flux-eco/aggregate-root
=======================

Manage aggregate roots described as json schema

1.1.0(4y ago)0331GPL-3.0-onlyPHPPHP &gt;=8.0

Since Apr 2Pushed 4y agoCompare

[ Source](https://github.com/flux-eco/aggregate-root)[ Packagist](https://packagist.org/packages/flux-eco/aggregate-root)[ Docs](https://fluxlabs.ch)[ RSS](/packages/flux-eco-aggregate-root/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (7)Dependencies (6)Versions (8)Used By (1)

flux-eco/aggregate-root
=======================

[](#flux-ecoaggregate-root)

Manage aggregate roots described as json schema. Evaluates and stores events in a storage. Up to now this component is binded to a mysql storage. The storage can be replaced by the implementation of a further adapter.

The usage is demonstrated by the following example application:

Usage
-----

[](#usage)

.env

```
AGGREGATE_ROOT_SCHEMA_DIRECTORY=schemas/domain
AGGREGATE_ROOT_STORAGE_CONFIG_ENV_PREFIX=EVENTS_
AGGREGATE_ROOT_EVENT_SCHEMA_FILE_PATH=../schemas/AggregateRootEvent.yaml
EVENTS_STORAGE_HOST=localhost
EVENTS_STORAGE_DRIVER=Pdo_Mysql
EVENTS_STORAGE_NAME=events
EVENTS_STORAGE_USER=user
EVENTS_STORAGE_PASSWORD=password
PROJECTION_APP_SCHEMA_DIRECTORY=../vendor/flux-eco/projection/schemas
PROJECTION_ECO_SCHEMA_DIRECTORY=schemas/projections
PROJECTION_STORAGE_CONFIG_ENV_PREFIX=PROJECTION_
PROJECTION_STORAGE_NAME=projection
PROJECTION_STORAGE_HOST=localhost
PROJECTION_STORAGE_DRIVER=Pdo_Mysql
PROJECTION_STORAGE_USER=user
PROJECTION_STORAGE_PASSWORD=password
STREAM_STORAGE_CONFIG_ENV_PREFIX=STREAM_
STREAM_STORAGE_NAME=stream
STREAM_STORAGE_HOST=localhost
STREAM_STORAGE_DRIVER=Pdo_Mysql
STREAM_STORAGE_USER=user
STREAM_STORAGE_PASSWORD=password
STREAM_TABLE_NAME=stream
STREAM_STATE_SCHEMA_FILE=../vendor/flux-eco/global-stream/schemas/State.yaml

```

schemas\\domain\\account.yaml

```
name: account
type: object
properties:
    aggregateId:
        type: string
        readOnly: true
    correlationId:
        type: string
        readOnly: true
    aggregateName:
        type: string
        const: todo
        readOnly: true
    sequence:
        type: integer
        readOnly: true
    createdDateTime:
        type: string
        format: date-time
        readOnly: true
    createdBy:
        type: string
        format: email
        readOnly: true
    changedDateTime:
        type: string
        format: date-time
        readOnly: true
    changedBy:
        type: string
        format: email
        readOnly: true
    rootObjectSchema:
        type: string
        const: v1
    rootObject:
        type: object
        properties:
            firstname:
                type: string
            lastname:
                type: string

```

schemas\\projections\\account.yaml

```
title: account
type: object
aggregateRootNames:
  - account
properties:
  projectionId:
    type: string
  firstname:
    type: string
    index: account.rootObject.firstname
  lastname:
    type: string
    index: account.rootObject.lastname

```

example.php

```
