A "from scratch" PHP-based implementation of Event-Sourcing

Overview

EventSourcing Workshop

In here, you will find a "from scratch" PHP-based implementation of Event-Sourcing, kept to a minimum on purpose, to allow workshop attendees to explore and experiment with its concepts.

DISCLAIMER: Not a production project

This is not a library nor production-ready project: this is an educational project. Its target audience is students and backend engineers that want to get better at abstracting/maintaining business logic.

Knowledge required

To work in this project, you need some rough knowledge about:

  • php
    • you should be familiar with php's syntax
    • the provided test suite and tooling should help you prevent mistakes, but you should have basic knowledge of how php runs and fails.
    • we use functional and object-oriented paradigms: you may be up for a crash-course, if you never saw code structured this way.
  • composer
    • php class autoloading and dependency installation is handled for you, but if something goes wrong, you should know some composer basics
  • sql
    • the entire workshop is based on SQLite databases: it's just files, but you need to know some very basic SQL
  • make
    • most repetitive tasks have been added to a Makefile: run make to see what's available
  • docker and docker-compose
    • to ensure everyone runs on the same environment, we run tests inside a docker container. Building images and starting/stopping containers is sufficient: we will not use any advanced docker features
    • don't worry too much if you don't: the Makefile should abstract most docker stuff away

Firing it up

Run:

make composer-install
make quality-assurance
make interactive-shell

Architecture


Exercises

Note: all exercises are under the watchful eye of static analysis and CS tooling. Use make quality-assurance to validate your current work!

  1. Standalone recording of a temperature
  2. Tracking the last recorded temperature at each location
  3. Tracking the average recorded temperature at each location, but in the database
  4. Send an alert when the temperature is below freezing point
  5. Payment aggregate
  6. Collaborative event-sourcing:
    • TODO: idea of mapping a speed-trap fine management process
    • TODO: idea of mapping a hotel reservation + stay process

License

This software is proprietary: please contact the author for permission to use, but for now, these sources are not freely reusable outside educational purposes. Yes: you are reading correctly, this is not MIT/BSD software :-P

Comments
  • Pin dependencies - autoclosed

    Pin dependencies - autoclosed

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | azjezz/psl | require | pin | ^2.0.3 -> 2.0.3 | | cuyz/valinor | require | pin | ^0.12.0 -> 0.12.0 | | doctrine/coding-standard (source) | require-dev | pin | ^9.0.0 -> 9.0.0 | | doctrine/dbal (source) | require | pin | ^3.3.7 -> 3.3.7 | | doctrine/migrations (source) | require-dev | pin | ^3.5 -> 3.5.1 | | lcobucci/clock | require | pin | ^2.2 -> 2.2.0 | | php-standard-library/psalm-plugin | require-dev | pin | ^2.0 -> 2.0.2 | | phpunit/phpunit (source) | require-dev | pin | ^9.5.21 -> 9.5.21 | | psalm/plugin-phpunit | require-dev | pin | ^0.17.0 -> 0.17.0 | | qossmic/deptrac-shim | require-dev | pin | ^0.23.0 -> 0.23.0 | | ramsey/uuid | require | pin | ^4.3.1 -> 4.3.1 | | roave/infection-static-analysis-plugin | require-dev | pin | ^1.21 -> 1.21.0 | | vimeo/psalm | require-dev | pin | ^4.24.0 -> 4.25.0 |

    Add the preset :preserveSemverRanges to your config if you don't want to pin your dependencies.


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

    enhancement invalid 
    opened by renovate[bot] 2
  • Lock file maintenance

    Lock file maintenance

    Mend Renovate

    This PR contains the following updates:

    | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed |

    🔧 This Pull Request updates lock files to use the latest dependency versions.


    Configuration

    📅 Schedule: Branch creation - "before 2am" in timezone UTC, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

    👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, click this checkbox. ⚠ Warning: custom changes will be lost.

    Read more information about the use of Renovate Bot within Laminas.

    renovate 
    opened by renovate[bot] 1
  • Update dependency cuyz/valinor to ^0.14.0

    Update dependency cuyz/valinor to ^0.14.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | cuyz/valinor | require | minor | ^0.13.0 -> ^0.14.0 |


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox. ⚠ Warning: custom changes will be lost.

    Read more information about the use of Renovate Bot within Laminas.

    renovate 
    opened by renovate[bot] 1
  • Pin dependency symfony/console to 6.1.3

    Pin dependency symfony/console to 6.1.3

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | symfony/console (source) | require-dev | pin | ^6.1 -> 6.1.3 |

    Add the preset :preserveSemverRanges to your config if you don't want to pin your dependencies.


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

    invalid 
    opened by renovate[bot] 1
  • Add exercises

    Add exercises

    Taken from #1, we need exercises.

    We also need to write an example implementation somewhere, to validate that the exercise can be performed by attendees (not to be committed).

    • [ ] provide example scenarios for attendees to build
      • [ ] Temperature monitoring
        • [ ] Pure logging
        • [ ] Record temperature monitoring (projection)
        • [ ] Record temperature alerting (policy)
      • [ ] Home alarm management
        • [ ] Aggregate design
        • [ ] Leave home
        • [ ] Return home
        • [ ] Intrusion detection
        • [ ] Policy that reacts to intrusion detection
    enhancement 
    opened by Ocramius 1
  • Add entrypoints for workshop attendees

    Add entrypoints for workshop attendees

    We need something like public/index.php or bin/console.

    We need to:

    • run some entry-points (happy path scenario about biz logic being executed)
    • run some projections
    • run some policies

    The entry-point should also provision the DB, if not already there.

    enhancement 
    opened by Ocramius 1
  • Working prototype - baseline for writing exercises for attendees

    Working prototype - baseline for writing exercises for attendees

    TODO:

    • [x] run CI on github - this project must be maintained long-term
      • [x] ~~configure renovate (post-merge)~~
      • [x] configure CI
      • [x] add a Makefile for easy usage
    • [x] provide example setup
      • [x] ~~provide bootstrapper~~ moved to #2
      • [x] provide integration tests
      • [x] provide documentation
    enhancement 
    opened by Ocramius 1
  • Update dependency doctrine/coding-standard to v10

    Update dependency doctrine/coding-standard to v10

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | doctrine/coding-standard (source) | require-dev | major | ^9.0.0 -> ^10.0.0 |


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox. ⚠ Warning: custom changes will be lost.

    Read more information about the use of Renovate Bot within Laminas.

    renovate 
    opened by renovate[bot] 0
  • Introducing initial exercises for the workshop attendees

    Introducing initial exercises for the workshop attendees

    Provides some of the #3 work.

    Still missing:

    • [ ] idea about event-storming (let's hope Miro works during the workshop)
    • [ ] a practical example of an event-sourced aggregate
    enhancement 
    opened by Ocramius 0
  • Update docker/setup-buildx-action action to v2

    Update docker/setup-buildx-action action to v2

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | docker/setup-buildx-action | action | major | v1 -> v2 |


    Release Notes

    docker/setup-buildx-action

    v2

    Compare Source


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    Read more information about the use of Renovate Bot within Laminas.

    renovate 
    opened by renovate[bot] 0
  • Update docker/build-push-action action to v3

    Update docker/build-push-action action to v3

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | docker/build-push-action | action | major | v2 -> v3 |


    Release Notes

    docker/build-push-action

    v3

    Compare Source


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    Read more information about the use of Renovate Bot within Laminas.

    renovate 
    opened by renovate[bot] 0
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    Awaiting Schedule

    These updates are awaiting their schedule. Click on a checkbox to get an update now.

    • [ ] Lock file maintenance

    Detected dependencies

    composer
    composer.json
    • azjezz/psl ^2.0.3
    • cuyz/valinor ^0.14.0
    • doctrine/dbal ^3.4.5
    • lcobucci/clock ^2.2
    • ramsey/uuid ^4.5.1
    • doctrine/coding-standard ^10.0.0
    • doctrine/migrations ^3.5
    • php-standard-library/psalm-plugin ^2.0
    • phpunit/phpunit ^9.5.21
    • psalm/plugin-phpunit ^0.17.0
    • qossmic/deptrac-shim ^0.24.0
    • roave/infection-static-analysis-plugin ^1.21
    • symfony/console ^6.1
    • vimeo/psalm ^4.24.0
    docker-compose
    docker-compose.yml
    dockerfile
    Dockerfile
    • ubuntu 22.04
    • composer 2.4.2
    github-actions
    .github/workflows/continuous-integration.yml
    • docker/setup-buildx-action v2
    • actions/checkout v3
    • docker/build-push-action v3

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    renovate 
    opened by renovate[bot] 0
Owner
Marco Pivetta
@Roave, @laminas and @doctrine. Pushing for better practices in the PHP ecosystem.
Marco Pivetta
Psalm plugin for patchlevel/event-sourcing

event-sourcing-psalm-plugin psalm plugin for event-sourcing library. installation composer require --dev patchlevel/event-sourcing-psalm-plugin confi

patchlevel 3 Jul 5, 2022
Because every Wedding RSVP website needs to follow DDD, CQRS, Hexagonal Architecture, Event Sourcing, and be deployed on Lambda.

Our Wedding Website Because every Wedding RSVP website needs to follow DDD, CQRS, Hexagonal Architecture, Event Sourcing, and be deployed on Lambda. ?

Edd Mann 3 Aug 21, 2022
The easiest way to get started with event sourcing in Laravel

Event sourcing for Artisans ?? This package aims to be the entry point to get started with event sourcing in Laravel. It can help you with setting up

Spatie 565 Sep 30, 2022
Learning about - Basic HTML & CSS, JSON, XML, Session & Cookies, CRUD Operations in Php using MySQL and Create MVC from scratch

This Project is based on course CSC 3215. Learning about - Basic HTML & CSS, JSON, XML, Session & Cookies, CRUD Operations in Php using MySQL and Create MVC (Model–View–Controller) from scratch. Just learning about web technologies, Not focusing on UI (Bootstrap or other 3rd-Party UI libraries or frameworks).

Alvi Hasan 5 Sep 9, 2022
Learn how to deploy Laravel 7 project in GCP from scratch

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Almujeer Uddin 2 Nov 21, 2021
This library is an implementation of League\Event for Slim Framework

Slim Event Dispatcher This library is an implementation of League\Event for Slim Framework. This works with the latest version of Slim (V3). Installat

Aneek Mukhopadhyay 7 Aug 23, 2022
A Laravel artisan based package to create the AWS (SES + SNS) infrastructure to receive email event notifications with Http/Https endpoint.

Laravel SES Tracking Setup the AWS infrastructure to handle email events using SES/SNS and http/s endpoints with a single Laravel artisan command. Thi

null 11 Apr 26, 2022
JsonCollectionParser - Event-based parser for large JSON collections (consumes small amount of memory)

Event-based parser for large JSON collections (consumes small amount of memory). Built on top of JSON Streaming Parser This packa

Max Grigorian 109 Aug 2, 2022
True coroutines for PHP>=8.1 without worrying about event loops and callbacks.

Moebius Pure coroutines for PHP 8.1. To promises and callbacks needed. Just pure parallel PHP code inside coroutines. Moebius Band: A loop with only o

Frode Børli 194 Sep 19, 2022
True coroutines for PHP>=8.1 without worrying about event loops and callbacks.

Moebius Pure coroutines for PHP 8.1. No promises and callbacks needed. Just pure parallel PHP code inside coroutines. Moebius Band: A loop with only o

Moebius for PHP 141 Jun 16, 2022
A high-performance event loop library for PHP

?? A high-performance event loop library for PHP ??

workbunny 10 Jun 27, 2022
PHP Event Emitter

InitPHP EventEmitter This library has been designed to emit events in its simplest and simplest form. Requirements PHP 5.6 or higher Installation comp

InitPHP 0 Jul 9, 2022
Php-file-iterator - FilterIterator implementation that filters files based on a list of suffixes, prefixes, and other exclusion criteria.

php-file-iterator Installation You can add this library as a local, per-project dependency to your project using Composer: composer require phpunit/ph

Sebastian Bergmann 7.1k Sep 27, 2022
This is a JSONPath implementation for PHP based on Stefan Goessner's JSONPath script.

JSONPath for PHP This is a JSONPath implementation for PHP based on Stefan Goessner's JSONPath script. JSONPath is an XPath-like expression language f

Sascha Greuel 97 Aug 31, 2022
An Infection + Last Man Standing Event plugin written for OwnagePE

KitPvPEvent An Infection + Last Man Standing Event plugin written for OwnagePE This plugin was a speedcode. I kinda woke up really late on the day I w

OwnagePE Network 2 May 26, 2022
Notify instructors about unconfirmed event registrations.

SAC Event Registration Reminder Folgende Idee: Es wird ein Reminder-Tool benötigt, welches Tourenleitende und Bergführer/innen per E-Mail daran erinne

Marko Cupic 2 Apr 25, 2022
Implement event systems, signal slots, intercepting filters, and observers.

zend-eventmanager Repository abandoned 2019-12-31 This repository has moved to laminas/laminas-eventmanager. zend-eventmanager is designed for the fol

Zend Framework 1.7k Sep 16, 2022
Allows installing Drupal extensions event if not compatible with installed drupal/core package

mglaman/composer-drupal-lenient Lenient with it, Drupal 10 with it. Why? The Drupal community introduced a lenient Composer facade that modified the d

Matt Glaman 8 Sep 21, 2022
Command and event buses interface and logic.

CoreBus - Command and Event buses interfaces Discrete command bus and domain event dispatcher interfaces for message based architectured projects. Dis

Makina Corpus 0 Feb 7, 2022