Git Product home page Git Product logo

broadway-demo's Introduction

Demo for Broadway - EventSourcing library for PHP

This repository contains a demo application to show how Broadway can be used within a Symfony application. The example is taken from the Practical Event Sourcing talk from Mathias Verraes.

For simplicity the demo uses the official DBAL event store and a custom DBAL read model implementation. You will need to have SQLite installed to run the demo.

build status

Running the demo

composer install
bin/console broadway:event-store:create
bin/console broadway:read-model:create
bin/console server:run

This demo doesn't have a GUI, only an API with the following endpoints:

Method Path Description
POST /basket Pick up a new basket, returns the basketId
POST /basket/{basketId}/addProduct Add a product to a basket (productId and productName should be given as form fields)
POST /basket/{basketId}/removeProduct Remove a product from a basket (productId as form field)
POST /basket/{basketId}/checkout Check out a basket
GET /advice/{productId} Retrieve Other people also bought this list
# pick up a new basket
$ curl -X POST http://localhost:8000/basket
{
  "id":"1bd683ac-f75d-403f-babc-82ddcdb33de7"
}

# add products to the basket
$ curl -d "productId=2009&productName=Incredibad" -X POST http://localhost:8000/basket/1bd683ac-f75d-403f-babc-82ddcdb33de7/addProduct
$ curl -d "productId=2011&productName=Turtleneck+%26+Chain" -X POST http://localhost:8000/basket/1bd683ac-f75d-403f-babc-82ddcdb33de7/addProduct
$ curl -d "productId=2013&productName=The+Wack+Album" -X POST http://localhost:8000/basket/1bd683ac-f75d-403f-babc-82ddcdb33de7/addProduct

# remove a product from the basket
curl -d "productId=2009" -X POST http://localhost:8000/basket/1bd683ac-f75d-403f-babc-82ddcdb33de7/removeProduct

# check out the basket
$ curl -X POST http://localhost:8000/basket/1bd683ac-f75d-403f-babc-82ddcdb33de7/checkout

# get _Other people also bought this_ list
$ curl http://localhost:8000/advice/2011
{
  "purchasedProductId": 2011,
  "otherProducts": {
    "2009": 1,
    "2013": 1
  }
}

Running the tests

To run all the tests:

./vendor/bin/phpunit

Code structure

  • Domain code can be found in src/Basket
  • ReadModel code can be found in src/ReadModel
  • Controllers can be found in src/Controllers

Note that there are two files for the services: services.yaml and domain.yaml. domain.yaml contains all the domain-specific services (CommandHandler, ReadModels, Repositories), while services.yaml contains domain-unspecific services (controllers etc).

The domain specific tests can be found in test/Basket and test/ReadModel

Note that there is a functional test in test/Functional

For more information, read our blog post about this demo: http://labs.qandidate.com/blog/2014/12/30/a-broadway-demo-application/

broadway-demo's People

Contributors

akondas avatar asm89 avatar bestit-espendiller avatar cordoval avatar dependabot-preview[bot] avatar dependabot[bot] avatar fritsjanb avatar ivastly avatar luismulinari avatar markredeman avatar othillo avatar ricbra avatar ruudk avatar rvdbogerd avatar wjzijderveld avatar wysow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

broadway-demo's Issues

Composer install doesn't work

Ruud /www $ git clone https://github.com/qandidate-labs/broadway-demo.git
Cloning into 'broadway-demo'...
remote: Counting objects: 81, done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 81 (delta 23), reused 81 (delta 23)
Unpacking objects: 100% (81/81), done.
Checking connectivity... done.
Ruud /www $ cd broadway-demo/
Ruud /www/broadway-demo $ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for doctrine/mongodb 1.1.6 -> satisfiable by doctrine/mongodb[1.1.6].
    - doctrine/mongodb 1.1.6 requires ext-mongo >=1.2.12,<1.6-dev -> the requested PHP extension mongo is missing from your system.

I don't have ext-mongo. So the most logical thing would be to first run vagrant up and then run composer install inside it?

simplify the demo setup

For historical reasons Broadway shipped with MySQL and Elasticsearch out of the box. This makes it a little difficult to set up. Now we have multiple event store and read model implementations.

I suggest to refactor this demo to use the simplest backing services as possible and in general simplify the project to get the demo up and running in no time for new users.

ansible provision fails on version 2.0.1.0

When running vagrant up the following error is shown on console:

 -------------------------
< TASK [Install packages] >
 -------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: argument of type 'NoneType' is not iterable
fatal: [default]: FAILED! => {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}

The issue is already reported at the ansible github repo: ansible/ansible#14664
and can be easily worked around by replacing 'package' with 'name'

My system is:

> lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description:    Linux Mint 17 Qiana
Release:    17
Codename:   qiana

And the ansible I'm running on:

> ansible --version
ansible 2.0.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

How can we browse the eventstore records ?

Hello,

I am trying to make the demo work but i cannot browse event storage.

Would it be possible to have a little help on how to setup mysql for eventstorage ?

I fact i added mysql as doctrine/dbal but executing "broadway:event-store:schema:init" doesn't show any schema or tables.

Thank you so much

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.