{"id":20131406,"url":"https://github.com/fabwu/dddinaction","last_synced_at":"2025-04-09T16:40:43.717Z","repository":{"id":81409241,"uuid":"138582399","full_name":"fabwu/dddinaction","owner":"fabwu","description":"PHP implementation of the DDD in Practice Pluralsight course","archived":false,"fork":false,"pushed_at":"2018-09-22T07:39:30.000Z","size":258,"stargazers_count":56,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"module-7","last_synced_at":"2025-03-23T18:52:11.202Z","etag":null,"topics":["ddd","php","symfony"],"latest_commit_sha":null,"homepage":"https://www.pluralsight.com/courses/domain-driven-design-in-practice","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabwu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-25T10:54:49.000Z","updated_at":"2024-11-07T12:16:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"7865be91-7358-4030-9b24-f954a8d007e4","html_url":"https://github.com/fabwu/dddinaction","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabwu%2Fdddinaction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabwu%2Fdddinaction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabwu%2Fdddinaction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabwu%2Fdddinaction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabwu","download_url":"https://codeload.github.com/fabwu/dddinaction/tar.gz/refs/heads/module-7","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248068889,"owners_count":21042575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddd","php","symfony"],"created_at":"2024-11-13T20:48:20.791Z","updated_at":"2025-04-09T16:40:43.710Z","avatar_url":"https://github.com/fabwu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DDD Snack Machine\n\n[![Build Status](https://travis-ci.com/fabwu/dddinaction.svg?branch=module-7)](https://travis-ci.com/fabwu/dddinaction)\n\nThis is a simple snack machine implemented in PHP and following the Domain Driven Design\nprinciples. Everything is based on the Pluralsight course \n[Domain Driven Design in Practice](https://www.pluralsight.com/courses/domain-driven-design-in-practice).\nYou can find the original C# source code [here](https://github.com/vkhorikov/DddInAction).\n\nThe repository contains the following branches each reflecting a module in the course:\n\n- `module-2` Starting with the First Bounded Context\n- `module-3` Introducing UI and Persistence Layers\n- `module-5` Extending the Bounded Context with Aggregates \u0026 Introducing Repositories\n- `module-6` Introducing the Second Bounded Context\n- `module-7` Working with Domain Events\n\nI couldn't implement everything exactly like Vladimir suggested it. Here is a list of \nthings I had to adapt for the PHP language:\n\n- I stored the snack machine with both money value types in the database. As a first \napproach I used sessions to overcome the state problem but this seems a bit like a overkill\nso I stored everything in the database. Therefore, I have to read and save the snack machine\nafter each action but I couldn't come up with a better solution.\n- I didn't have to break encapsulation or add new constructors because Doctrine discover\nthe properties via reflection and can create the proxies.\n- I had to use annotations to describe the orm mapping. I don't really like them because they\nclutter up my entities with persistence logic but the other options (xml, yml, php) don't provide\nrefactoring or auto-completion.\n- Doctrine doesn't support entities on embeddables so I just use the id as an integer column.\n- The domain events implementation is inspired from [this blogpost](https://beberlei.de/2013/07/24/doctrine_and_domainevents.html).\nI tried to use a more type save approach but it's still ugly due to the php type system. You also have\nto register all domain events handler manually. A compiler pass collects all tagged handlers and adds them\nto the dispatcher.\n\nI also tried to encapsulate the modules via [composer's path setting](https://getcomposer.org/doc/05-repositories.md#path). This was not useful\nbecause it provides no encapsulation (e.g. Domain module can access UI module) and slows\ndown development.\n\n## Installation\n\nRun the following commands to install and start the server.\n```\ncomposer install\nphp bin/console doctrine:migrations:migrate\nphp -S localhost:8080 -t public/\n```\nYou can then access the application under http://localhost:8080\n\n# Testing\n\nRun the tests with the following command:\n```\n# Unit Tests\nvendor/bin/phpunit --configuration phpunit.xml --testsuite unit\n\n# Integration Tests\nvendor/bin/phpunit --configuration phpunit.xml --testsuite integration\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabwu%2Fdddinaction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabwu%2Fdddinaction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabwu%2Fdddinaction/lists"}