Skip to content

Commit

Permalink
rename to laravel-event-sourcing
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Sep 20, 2019
1 parent 38394bd commit e9594c4
Show file tree
Hide file tree
Showing 131 changed files with 592 additions and 733 deletions.
156 changes: 2 additions & 154 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,159 +1,7 @@
# Changelog

All notable changes to `laravel-event-projector` will be documented in this file
All notable changes to `laravel-event-sourcing` will be documented in this file:

## 3.1.2 - 2019-09-12

- fix for replay events command with no-interaction flag (#197)

## 3.1.1 - 2019-09-06

- Add schemaless-attributes again for Eloquent models

## 3.1.0 - 2019-09-05

- re-introduce the `stored_event_model` config

## 3.0.1 - 2019-09-05

- make sure events are retrieved in the correct order

## 3.0.0 - 2019-09-04

- don't require eloquent for storing and retrieving events
- add support for Laravel 6

## 2.8.2 - 2019-09-04

- fix for projectors with non-public methods

## 2.8.1 - 2019-07-19

- improve test methods

## 2.8.0 - 2019-07-19

- added aggregate test methods

## 2.7.0 - 2019-07-18

- added `event_class_map` to alias your event classes which allows for refactoring after events have been fired

## 2.6.3 - 2019-06-14

- fix warnings in console commands

## 2.6.2 - 2019-06-04

- fix stubs

## 2.6.1 - 2019-05-16

- fix for disabling the event listener auto discovery

## 2.6.0 - 2019-05-06

- add `stored-event-model` option to the replay command

## 2.5.0 - 2019-05-06

- allow to specify the model to be used by an aggregate for retrieving/peristing events by adding a `$storedEventModel` on it

## 2.4.0 - 2019-04-23

- allow to specify the queue that should be used on the event

## 2.3.0 - 2019-04-16

- add `list` command

## 2.2.0 - 2019-04-16

- automatically register event handlers

## 2.1.1 - 2019-04-13

- stubs don't use `handlesEvents` anymore

## 2.1.0 - 2019-04-13

- add autodetection for event handling methods

## 2.0.5 - 2019-04-09

- fix storable event command

## 2.0.4 - 2019-04-09

- fix `make` commands

## 2.0.3 - 2019-04-09

- make service provider final

## 2.0.2 - 2019-04-09

- make service provider non final

## 2.0.1 - 2019-04-09

- fix `HandleStoredEventJob`

## 2.0.0 - 2019-04-08

- added support for aggregates
- support a new `handleEvent` property for event handlers
- removed all support for projector statusses
- the `rebuild` command has been removed. It's been replace by the `--from` flag on event replay

## 1.3.2 - 2018-02-27

- add support for Laravel 5.8

## 1.3.1 - 2018-12-06

- fix missing `use` statement in `EventHandlerCollection`

## 1.3.0 - 2018-11-19

- add `stored_event_job` to config file

## 1.2.0 - 2018-10-30

- add `isProjecting`

## 1.1.2 - 2018-09-27

- fix for working with a custom `StoredEvent`, `ProjectorStatus`

## 1.1.1 - 2018-09-01

- add support for Laravel 5.7

## 1.1.0 - 2018-09-01

- add ability to add tags to be displayed in Horizon

## 1.0.5 - 2018-08-13

- moaarrr fixes for replaying events using a custom `StoredEvent` model

## 1.0.4 - 2018-08-13

- fix replaying events using a custom `StoredEvent` model

## 1.0.3 - 2018-08-05

- fixed some typos in the config file

## 1.0.2 - 2018-07-29

- fix name of used env variable that determines the queue name

## 1.0.1 - 2018-07-28

- fix reactor stub

## 1.0.0 - 2018-07-13
## 3.2.0 - 2019-09-20

- initial release
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Event sourcing for Artisans 📽

[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-event-projector.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-event-projector)
[![Build Status](https://img.shields.io/travis/spatie/laravel-event-projector/master.svg?style=flat-square)](https://travis-ci.org/spatie/laravel-event-projector)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-event-sourcing.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-event-sourcing)
[![Build Status](https://img.shields.io/travis/spatie/laravel-event-sourcing/master.svg?style=flat-square)](https://travis-ci.org/spatie/laravel-event-sourcing)
[![StyleCI](https://styleci.io/repos/133496112/shield?branch=master)](https://styleci.io/repos/133496112)
[![Quality Score](https://img.shields.io/scrutinizer/g/spatie/laravel-event-projector.svg?style=flat-square)](https://scrutinizer-ci.com/g/spatie/laravel-event-projector)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-event-projector.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-event-projector)
[![Quality Score](https://img.shields.io/scrutinizer/g/spatie/laravel-event-sourcing.svg?style=flat-square)](https://scrutinizer-ci.com/g/spatie/laravel-event-sourcing)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-event-sourcing.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-event-sourcing)

This package aims to be the entry point to get started with event sourcing in Laravel. It can help you with setting up aggregates, projectors, and reactors.

If you've never worked with event sourcing, or are uncertain about what aggregates, projectors and reactors are head over to the getting familiar with event sourcing section [in our docs](https://docs.spatie.be/laravel-event-projector/v3/getting-familiar-with-event-sourcing/introduction).
If you've never worked with event sourcing, or are uncertain about what aggregates, projectors and reactors are head over to the getting familiar with event sourcing section [in our docs](https://docs.spatie.be/laravel-event-sourcing/v3/getting-familiar-with-event-sourcing/introduction).

Event sourcing might be a good choice for your project if:

Expand All @@ -19,12 +19,12 @@ Event sourcing might be a good choice for your project if:
If you want to skip to reading code immediately, here are some example apps. In each of them, you can create accounts and deposit or withdraw money.

- [Larabank built traditionally without event sourcing](https://github.com/spatie/larabank-traditional)
- [Larabank built with projectors](https://github.com/spatie/larabank-event-projector)
- [Larabank built with aggregates and projectors](https://github.com/spatie/larabank-event-projector-aggregates)
- [Larabank built with projectors](https://github.com/spatie/larabank-event-sourcing)
- [Larabank built with aggregates and projectors](https://github.com/spatie/larabank-event-sourcing-aggregates)

## Documentation

You can find installation instructions and detailed instructions on how to use this package at [the dedicated documentation site](https://docs.spatie.be/laravel-event-projector).
You can find installation instructions and detailed instructions on how to use this package at [the dedicated documentation site](https://docs.spatie.be/laravel-event-sourcing).

## Changelog

Expand Down
21 changes: 16 additions & 5 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

Because there are many breaking changes we cannot give you a waterproof list of steps to provide. There are many edge cases this guide does not cover. We accept PRs to improve this guide.

## From v3 to v4

The only change in this version is the naming change from `laravel-event-projector` to `laravel-event-sourcing`

To upgrade you just have to perform these steps:
1. rename `config/laravel-event-projector.php` to `config/laravel-event-sourcing.php`
2. `laravel-event-projector:v3` to `laravel-event-sourcing:v3` and run `composer update`
3. The namespace has changed, so you need to replace `Spatie\EventSourcing` by `Spatie\EventSourcing` in your entire project

## From v2 to v3

- Add a `stored_event_repository` config key with the following value: `\Spatie\EventSourcing\EloquentStoredEventRepository::class`
- If you're using a different model for event storage:
1. Make sure the model extends `\Spatie\EventSourcing\Models\EloquentStoredEvent`


## From v1 to v2

- Add a nullable `aggregate_uuid` field in the `stored_events` table
Expand All @@ -10,8 +26,3 @@ Because there are many breaking changes we cannot give you a waterproof list of
- In v1 streams were used to track if events came in the right order. All support for event streams has been removed. If for your projectors the order of events is imports, use a queued projector.
- v1 tracked which events were already processed by a given event handler. In v2 all functionality around projector statusses is removed. It's now your own resposibility that you give all projectors the right events.

## From v2 to v3

- Add a `stored_event_repository` config key with the following value: `\Spatie\EventProjector\EloquentStoredEventRepository::class`
- If you're using a different model for event storage:
1. Make sure the model extends `\Spatie\EventProjector\Models\EloquentStoredEvent`
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "spatie/laravel-event-projector",
"name": "spatie/laravel-event-sourcing",
"description": "Event sourcing for artisans",
"keywords": [
"spatie",
"laravel-event-projector",
"laravel-event-sourcing",
"event",
"sourcing",
"aggregates",
"projectors",
"reactors"
],
"homepage": "https://github.com/spatie/laravel-event-projector",
"homepage": "https://github.com/spatie/laravel-event-sourcing",
"license": "MIT",
"authors": [
{
Expand Down Expand Up @@ -40,12 +40,12 @@
},
"autoload": {
"psr-4": {
"Spatie\\EventProjector\\": "src"
"Spatie\\EventSourcing\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Spatie\\EventProjector\\Tests\\": "tests"
"Spatie\\EventSourcing\\Tests\\": "tests"
},
"files": [
"tests/TestClasses/AutoDiscoverEventHandlers/functions.php"
Expand All @@ -62,10 +62,10 @@
"extra": {
"laravel": {
"providers": [
"Spatie\\EventProjector\\EventProjectorServiceProvider"
"Spatie\\EventSourcing\\EventSourcingServiceProvider"
],
"aliases": {
"Projectionist": "Spatie\\EventProjector\\Facades\\EventProjector"
"Projectionist": "Spatie\\EventSourcing\\Facades\\EventSourcing"
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions config/event-projector.php → config/event-sourcing.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/*
* Projectors are classes that build up projections. You can create them by performing
* `php artisan event-projector:create-projector`. When not using auto-discovery,
* `php artisan event-sourcing:create-projector`. When not using auto-discovery,
* Projectors can be registered in this array or a service provider.
*/
'projectors' => [
Expand All @@ -21,7 +21,7 @@

/*
* Reactors are classes that handle side-effects. You can create them by performing
* `php artisan event-projector:create-reactor`. When not using auto-discovery
* `php artisan event-sourcing:create-reactor`. When not using auto-discovery
* Reactors can be registered in this array or a service provider.
*/
'reactors' => [
Expand All @@ -44,23 +44,23 @@
/*
* This class is responsible for storing events in the EloquentStoredEventRepository.
* To add extra behaviour you can change this to a class of your own. It should
* extend the \Spatie\EventProjector\Models\EloquentStoredEvent model.
* extend the \Spatie\EventSourcing\Models\EloquentStoredEvent model.
*/
'stored_event_model' => \Spatie\EventProjector\Models\EloquentStoredEvent::class,
'stored_event_model' => \Spatie\EventSourcing\Models\EloquentStoredEvent::class,

/*
* This class is responsible for storing events. To add extra behaviour you
* can change this to a class of your own. The only restriction is that
* it should implement \Spatie\EventProjector\StoredEventRepository.
* it should implement \Spatie\EventSourcing\StoredEventRepository.
*/
'stored_event_repository' => \Spatie\EventProjector\EloquentStoredEventRepository::class,
'stored_event_repository' => \Spatie\EventSourcing\EloquentStoredEventRepository::class,

/*
* This class is responsible for handling stored events. To add extra behaviour you
* can change this to a class of your own. The only restriction is that
* it should extend \Spatie\EventProjector\HandleDomainEventJob.
* it should extend \Spatie\EventSourcing\HandleDomainEventJob.
*/
'stored_event_job' => \Spatie\EventProjector\HandleStoredEventJob::class,
'stored_event_job' => \Spatie\EventSourcing\HandleStoredEventJob::class,

/*
* Similar to Relation::morphMap() you can define which alias responds to which
Expand All @@ -72,9 +72,9 @@
/*
* This class is responsible for serializing events. By default an event will be serialized
* and stored as json. You can customize the class name. A valid serializer
* should implement Spatie\EventProjector\EventSerializers\Serializer.
* should implement Spatie\EventSourcing\EventSerializers\Serializer.
*/
'event_serializer' => \Spatie\EventProjector\EventSerializers\JsonEventSerializer::class,
'event_serializer' => \Spatie\EventSourcing\EventSerializers\JsonEventSerializer::class,

/*
* When replaying events, potentially a lot of events will have to be retrieved.
Expand All @@ -86,9 +86,9 @@
/*
* In production, you likely don't want the package to auto-discover the event handlers
* on every request. The package can cache all registered event handlers.
* More info: https://docs.spatie.be/laravel-event-projector/v2/advanced-usage/discovering-projectors-and-reactors
* More info: https://docs.spatie.be/laravel-event-sourcing/v2/advanced-usage/discovering-projectors-and-reactors
*
* Here you can specify where the cache should be stored.
*/
'cache_path' => storage_path('app/event-projector'),
'cache_path' => storage_path('app/event-sourcing'),
];
2 changes: 1 addition & 1 deletion docs/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: v3
slogan: Event Sourcing for Artisans
githubUrl: https://github.com/spatie/laravel-event-projector
githubUrl: https://github.com/spatie/laravel-event-sourcing
branch: master
---
6 changes: 3 additions & 3 deletions docs/advanced-usage/discovering-projectors-and-reactors.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ weight: 5

By default the package will automatically discover all projectors and reactors and will register them at the projectionist.

If you want to see a list of the discovered projectors and reactors perform the `event-projector:list` Artisan command. Here's how the output could look like:
If you want to see a list of the discovered projectors and reactors perform the `event-sourcing:list` Artisan command. Here's how the output could look like:

<img src="../../images/list.png" />

## Caching discovered projectors and reactors

In production, you likely do not want the package to scan all of your classes on every request. Therefore, during your deployment process, you should run the `event-projector:cache-event-handlers` Artisan command to cache a manifest of all of your application's projectors and reactors. This manifest will be used by the package to speed up the registration process. The `event-projector:clear-event-handlers` command may be used to destroy the cache.
In production, you likely do not want the package to scan all of your classes on every request. Therefore, during your deployment process, you should run the `event-sourcing:cache-event-handlers` Artisan command to cache a manifest of all of your application's projectors and reactors. This manifest will be used by the package to speed up the registration process. The `event-sourcing:clear-event-handlers` command may be used to destroy the cache.

## Disabling discovery

If you want to turn off auto-discovery and want to enforce manually registration of projectors and reactors, just set the `auto_discover_projectors_and_reactors` key in the `event-projector` config file to an empty array.
If you want to turn off auto-discovery and want to enforce manually registration of projectors and reactors, just set the `auto_discover_projectors_and_reactors` key in the `event-sourcing` config file to an empty array.
4 changes: 2 additions & 2 deletions docs/advanced-usage/handling-exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ title: Handling exceptions
weight: 4
---

The `event-projector` config file has a key, `catch_exceptions`, that determines what will happen should a projector or reactor throw an exception. If this setting is set to `false`, exceptions will not be caught and your app will come to a grinding halt.
The `event-sourcing` config file has a key, `catch_exceptions`, that determines what will happen should a projector or reactor throw an exception. If this setting is set to `false`, exceptions will not be caught and your app will come to a grinding halt.

If `catch_exceptions` is set to `true`, and an projector or reactor throws an exception, all other projectors and reactors will still get called. The `Projectionist` will catch all exceptions and fire the `EventHandlerFailedHandlingEvent`. That event contains these public properties:

- `eventHandler`: The projector or reactor that could not handle the event.
- `storedEvent`: The instance of `Spatie\EventProjector\Models\StoredEvent` that could not be handled.
- `storedEvent`: The instance of `Spatie\EventSourcing\Models\StoredEvent` that could not be handled.
- `exception`: The exception thrown by the `EventHandler`.

It will also call the `handleException` method on the projector or reactor that threw the exception. It will receive the thrown error as the first argument. If you throw an exception in `handleException`, the `Projectionist` will not catch it and your php process will fail.
Loading

0 comments on commit e9594c4

Please sign in to comment.