Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xyhan/symfony6-event-sourcing
A quick example of a Symfony project using event sourcing
https://github.com/xyhan/symfony6-event-sourcing
broadway event-sourcing php symfony
Last synced: 9 days ago
JSON representation
A quick example of a Symfony project using event sourcing
- Host: GitHub
- URL: https://github.com/xyhan/symfony6-event-sourcing
- Owner: XyHan
- License: gpl-3.0
- Created: 2023-09-19T09:33:48.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-14T18:39:15.000Z (2 months ago)
- Last Synced: 2024-09-15T23:08:40.737Z (2 months ago)
- Topics: broadway, event-sourcing, php, symfony
- Language: PHP
- Homepage:
- Size: 98.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Symfony6 EventSourcing with Broadway
This short example shows how to create an event sourced User and to use it with Symfony Security
### Quick Start
This project runs with docker. To start the needed containers, simply use the command
`make start`### Database
First of all, you need to set **DB_PASSWORD** env var.Then change the **DATABASE_URL** var from .env with default params:
- user: root
- password: the **DB_PASSWORD** valueTo create the database, you need to run the following command
`docker exec -it s6es-php bash -c "bin/console doctrine:database:create" `### Event Store
To create the Event Store, you need to run the following command
`docker exec -it s6es-php bash -c "bin/console broadway:event-store:create" `### User ReadModel
To create the mysql table of the user read model, you need to run the following command
`docker exec -it s6es-php bash -c "bin/console broadway:read-model:create rm_user" `### Set the project host
In your `/etc/hosts` add `127.0.0.1 s6es.local`### Create a new user
From a terminal, send the following POST request
```
curl -X POST http://s6es.local:8181/api/users/register
-H 'Content-Type: application/json'
-d '{"username": "Test","password": "changeme!","email": "[email protected]","roles": ["ROLE_USER"]}'
```The api should return a response as following
`[{"uuid": "40927741-1dc6-4092-8f8f-29991a6829d0","username": "Test"}]`In the database, you should see new lines in tables `events`, `rm_user` and `user`
### Login
From a terminal, send the following GET request
```
curl -X GET http://s6es.local:8181/api/login
-H 'Content-Type: application/json'
-d '{"password": "changeme!","username": "Test"}'
```The api should return a response as following
`{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2OTUxMzQ4OTMsImV4cCI6MTY5NTEzODQ5Mywicm9sZXMiOlsiUk9MRV9VU0VSIl0sInVzZXJuYW1lIjoiUm9iaW4ifQ.YF7wdlG2VgoqPor3jlt1jWcSgnlx0iLLlKuZ9iUysAf8xsP7J_uuRUirrO0INAq4nuiyuW0CTr-tDDO0B2SCSL4o7mg2PXCroA5EGpIwFFUmOAyUCZG0y_wa2rV4Xk31yQ0MLkQrcoDHcjdJgsx1mmJYTUrnk-nU9_Ht8qT85wlMfIO9Jib0laM9axPjgs-olkLBuN-XptJ4_jJuGWwrbucgO6DxRx6h_iHeS5y4JQtplDdtKXFNU1aTg2Iom3wSxtRhHBAV4G3dC61D1Gza7DSYmqkW-RunoNnQsdHUozlgV7UwwYQ8THfNDuQb9SWJTq5rqMFZsq51z_ziks3VpA"
}`