Code Monkey home page Code Monkey logo

php-ddd-cargo-sample's Introduction

php-ddd-cargo-sample

PHP 5.4+ port of the cargo sample used in Eric Evans Domain-Driven Design book

Scrutinizer Quality Score Build Status

CQRS & ES?

The original cargo sample is not based on CQRS and EventSourcing. However, you may have read something about it in relation to Domain-Driven Design. The php-ddd-cargo-sample shows you the original approach using application services, a combined write and read model and an ORM (Doctrine in our case) to hide the persistence layer. This is still a very good and valid approach but CQRS and EventSourcing gets a lot of attention these days because it offers a great way to tackle complex problems.

Our suggestion is that you have a look at the cargo example and also at proophessor-do.

Proophessor-do demonstrates CQRS and ES using prooph components and it is different then other example applications.

Proophessor-do is incomplete and you are ask to get the job done. This is a great way to learn more about CQRS and EventSourcing. Don't worry, the prooph community is available in a chat to help you with your task. See the HALL OF FAME. The first tasks are already done and the next ones in progress. So what are you waiting for? Go pick up a task, too!

Ok, you would like to explore the cargo sample first? Just read on. It starts with the next heading.

Goal of the Project

We want to show the PHP way of implementing Domain-Driven Design with the help of the original Cargo sample used in Eric Evans book Domain-Driven Design: Tackling Complexity in the Heart of Software. This has already been done using java and a C# version is also available.

It is not the one way to apply DDD, but should help you understand the theory and gives you a starting point. Also see the Caveats of the java implementation. The same applies for our version.

The PHP port is work in progress. Your welcome to fork the repo and help finishing the cargo sample application.

The application layer is based on ZF2 and we use Doctrine2 to persist our aggregates. This would be a common combination in a large PHP project but both frameworks are not required. They just make our life easier and let us focus on the Domain-Driven Design implementation. Both can be replaced with any other PHP based components.

Iterative Implementation

To go with you when you read the book, our sample has a release of each chapter. So you can simply git checkout ChapterOne and you only get the starting view of the domain with just to entities Cargo and Voyage. Our application evolves chapter by chapter the more knowledge we get about the domain. Each chapter ships with it's own review, where you can find additional information about the implementation, tips and tricks and many more.

Installation

See the Installation file.

Useful DDD tools

Check our collection of DDD Tools and Libs.

Become a member

If you want to share your experience with other DDD enthusiasts or want to ask a question about DDD then the DDDinPHP google group is good place to do so.

You can find more DDD stuff like interesting articles and related libraries on the PhpFriendsOfDdd/state-of-the-union project.

Project Structure

There is no problem if you don't know the structure of a ZF2 application. All the important parts like the domain and the infrastructure implementation can be found in the namespace of the CargoBackend module.

Note: Project structure has changed in ChapterFour. In ChapterOne - ChapterThree the domain and infrastructure classes were included in the Application module!

Behavior Driven Design

All features of the application are described in feature files. You can find them in the features folder of the project. We make use of Behat and Mink to test our business expectations.

You can run the feature tests by navigating to the project root and start the selenium server shipped with the sample app: java -jar bin/selenium-server-standalone-2.37.0.jar After the server started successfully open another console, navigate to project root again and run Behat with the command php bin/behat.

*Note: If it does not work, check that the behat file is executable.

Unit Tests

Unit Tests are of course also available. You can find them in module/CargoBackend/tests. Got to the directory and simply run phpunit.

Note: Project structure has changed in ChapterFour. In ChapterOne - ChapterThree the test classes were included in the Application module!

Support

If you have any problems with the application please let me know and send me an email kontakt[at]codeliner[dot]ws or open a GitHub issue. Same applies if you have a question or a feature wish. Maybe I've missed a concept that you hoped to find in the example.

Chapter Overview

The chapter overview has moved to the PHP DDD Cargo Sample project page

Contributing

See the CONTRIBUTING file.

TODO

  • Provide vagrant support for simple application set up [not started]
  • Improve project pages (include reviews, DDD tools, ...) [not started]
  • Review of ChapterFour [in progress]
  • Implement ChapterFive [not started]
    • Switch to ValueObjects and use VOs whenever possible
    • Add reroute Cargo use case
    • Add HandlingEvents
    • Add delivery progress use cases

php-ddd-cargo-sample's People

Contributors

codeliner avatar

Watchers

Rico Moorman avatar James Cloos avatar  avatar

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.