Main patterns: DDD, CQRS, Event Sourcing
CQRS command bus was taken from Tactican http://tactician.thephpleague.com
Event Sourcing implementation based on Broadway https://github.com/broadway/broadway
Booth Symfony bundles was spotted from https://github.com/jorge07/symfony-4-es-cqrs-boilerplate one of the best skeleton for DDD which i have ever seen. In real project i will just fork it, but to study i will implement it self.
The domain layer will be divided to next domains:
- User SignUp, SignIn, Unregister, Authorization, Inentification
- Product Keep information of available products and them types(Book is one of the type) on the storage, and reduce/increase that amount
- Order The "heart" of the project, here should initialize main events what should initialize "Purchase" and "Delivery" processes, here it is necessary to implement own Customer entity and OrderItem entity, what should stay even at user or product will be removed.
- Profile Just profile information, update and remove it when user unregister self, or ask it by GDPR reason
$ git clone$ composer install- Setup DB in the .env file required ENV params:
- DATABASE_HOST=127.0.0.1
- DATABASE_PORT=3306
- DATABASE_NAME=ddd-shop
- DATABASE_USER=root
- DATABASE_PASS=Test1234
-
Create database and tables
$ php ./bin/console d:d:c$ php ./bin/console d:s:c$ php ./bin/console d:m:e --up 20180908190647
NB! Do not use that solution on live servers. Only migrations is available there!
-
Run serve
- php ./bin/console s:r
NB! Do not use that solution on live servers. You have to setup normal web server. Ngix or Apache
Create new user
$ php ./bin/console app:create-user email@email.ru password
Create new product
$ php ./bin/console app:create-product NAME {product_on_stock} {price}
$ curl -d "email=email@gmail.com&password=password" -X POST http://localhost:8000/api/users
$ curl -X DELETE http://localhost:8000/api/user/{_USER_UUID_}
$ curl -X GET http://127.0.0.1:8000/api/products/{_PAGE_}
$ curl -d "user_uuid={_USER_UUID_}&product_uuid={_PRODUCT_UUID_}&amount={_AMOUNT_}" -X POST http://127.0.0.1:8000/api/purchase
$ curl -X GET http://127.0.0.1:8000/api/orders/{_USER_UUID_}/{_PAGE_}
$ curl -X PUT http://127.0.0.1:8000/api/profile/{_USER_UUID_} -d "address_city=City&address_street=Street&address_house_number=1&contact_email=email@email.ru&contact_phone=123123"
The goal seems unattainable until it is achieved