├── public
├── img
│ ├── 1c.png
│ ├── 1d.png
│ ├── 5d.png
│ ├── 10c.png
│ ├── 20d.png
│ ├── 25c.png
│ ├── Gum.png
│ ├── Icon.png
│ ├── Soda.png
│ └── Chocolate.png
└── index.php
├── config
├── packages
│ ├── routing.yaml
│ ├── dev
│ │ └── routing.yaml
│ ├── twig.yaml
│ ├── doctrine_migrations.yaml
│ ├── doctrine.yaml
│ ├── prod
│ │ └── doctrine.yaml
│ └── framework.yaml
├── routes
│ ├── annotations.yaml
│ └── dev
│ │ └── twig.yaml
├── bundles.php
└── services.yaml
├── src
├── Domain
│ ├── Common
│ │ ├── DomainEvent.php
│ │ ├── InvalidOperationException.php
│ │ ├── ValueObject.php
│ │ ├── Utility.php
│ │ ├── Handler.php
│ │ ├── AggregateRoot.php
│ │ └── Entity.php
│ ├── Atm
│ │ ├── PaymentGateway.php
│ │ ├── AtmRepository.php
│ │ ├── BalanceChangedEvent.php
│ │ ├── AtmDto.php
│ │ └── Atm.php
│ ├── SnackMachine
│ │ ├── SnackRepository.php
│ │ ├── SnackMachineRepository.php
│ │ ├── SnackMachineDto.php
│ │ ├── Slot.php
│ │ ├── Snack.php
│ │ ├── SnackPile.php
│ │ └── SnackMachine.php
│ ├── Management
│ │ ├── HeadOfficeRepository.php
│ │ ├── BalanceChangedEventHandler.php
│ │ └── HeadOffice.php
│ └── SharedKernel
│ │ └── Money.php
├── Infrastructure
│ ├── PaymentGatewayStub.php
│ ├── Repository
│ │ ├── DoctrineSnackRepository.php
│ │ ├── DoctrineHeadOfficeRepository.php
│ │ ├── DoctrineAtmRepository.php
│ │ └── DoctrineSnackMachineRepository.php
│ ├── DomainHandlerCompilerPass.php
│ ├── Migrations
│ │ ├── Version20180502180448.php
│ │ ├── Version20180516161021.php
│ │ ├── Version20180607093723.php
│ │ └── Version20180607235635.php
│ └── DomainEventDispatcher.php
├── UI
│ ├── HomeController.php
│ ├── AtmController.php
│ ├── HeadOfficeController.php
│ └── SnackMachineController.php
└── Kernel.php
├── .gitignore
├── .travis.yml
├── .env
├── phpunit.xml
├── templates
├── base.html.twig
├── home.html.twig
├── atm.html.twig
├── head-office.html.twig
└── snack-machine.html.twig
├── tests
├── unit
│ ├── SnackPileTest.php
│ ├── HeadOfficeTest.php
│ ├── AtmTest.php
│ ├── MoneyTest.php
│ └── SnackMachineTest.php
└── integration
│ └── IntegrationTest.php
├── LICENSE
├── bin
└── console
├── composer.json
├── README.md
└── symfony.lock
/public/img/1c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/1c.png
--------------------------------------------------------------------------------
/public/img/1d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/1d.png
--------------------------------------------------------------------------------
/public/img/5d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/5d.png
--------------------------------------------------------------------------------
/public/img/10c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/10c.png
--------------------------------------------------------------------------------
/public/img/20d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/20d.png
--------------------------------------------------------------------------------
/public/img/25c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/25c.png
--------------------------------------------------------------------------------
/public/img/Gum.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/Gum.png
--------------------------------------------------------------------------------
/public/img/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/Icon.png
--------------------------------------------------------------------------------
/public/img/Soda.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/Soda.png
--------------------------------------------------------------------------------
/config/packages/routing.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | router:
3 | strict_requirements: ~
4 |
--------------------------------------------------------------------------------
/config/packages/dev/routing.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | router:
3 | strict_requirements: true
4 |
--------------------------------------------------------------------------------
/public/img/Chocolate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabwu/dddinaction/HEAD/public/img/Chocolate.png
--------------------------------------------------------------------------------
/config/routes/annotations.yaml:
--------------------------------------------------------------------------------
1 | controllers:
2 | resource: ../../src/UI/
3 | type: annotation
4 |
--------------------------------------------------------------------------------
/config/routes/dev/twig.yaml:
--------------------------------------------------------------------------------
1 | _errors:
2 | resource: '@TwigBundle/Resources/config/routing/errors.xml'
3 | prefix: /_error
4 |
--------------------------------------------------------------------------------
/src/Domain/Common/DomainEvent.php:
--------------------------------------------------------------------------------
1 | symfony/framework-bundle ###
4 | /public/bundles/
5 | /var/
6 | /vendor/
7 | ###< symfony/framework-bundle ###
8 |
--------------------------------------------------------------------------------
/config/packages/twig.yaml:
--------------------------------------------------------------------------------
1 | twig:
2 | paths: ['%kernel.project_dir%/templates']
3 | debug: '%kernel.debug%'
4 | strict_variables: '%kernel.debug%'
5 |
--------------------------------------------------------------------------------
/src/Domain/Atm/PaymentGateway.php:
--------------------------------------------------------------------------------
1 | isEquals($obj);
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Domain/SnackMachine/SnackMachineRepository.php:
--------------------------------------------------------------------------------
1 | delta = $delta;
16 | }
17 |
18 | public function getDelta(): float
19 | {
20 | return $this->delta;
21 | }
22 | }
--------------------------------------------------------------------------------
/.env:
--------------------------------------------------------------------------------
1 | # This file is a "template" of which env vars need to be defined for your application
2 | # Copy this file to .env file for development, create environment variables when deploying to production
3 | # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
4 |
5 | ###> symfony/framework-bundle ###
6 | APP_ENV=dev
7 | APP_SECRET=bfc22997577a49fa286b7dc9c1e26990
8 | #TRUSTED_PROXIES=127.0.0.1,127.0.0.2
9 | #TRUSTED_HOSTS=localhost,example.com
10 | ###< symfony/framework-bundle ###
11 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | This is a simple snack machine implemented in PHP and following the Domain Driven Design 9 | principles. Everything is based on the Pluralsight course 10 | Domain Driven Design in Practice 11 | by Vladimir Khorikov. 12 |
13 |Click on the button:
14 |15 | ATM 16 | Head Office 17 |
18 |
11 |
{{ atm.moneyInside.oneCentCount }}
12 |
{{ atm.moneyInside.tenCentCount }}
13 |
{{ atm.moneyInside.quarterCount }}
14 |
16 |
{{ atm.moneyInside.oneDollarCount }}
17 |
{{ atm.moneyInside.fiveDollarCount }}
18 |
{{ atm.moneyInside.twentyDollarCount }}
19 |
| ID | 15 |Money Inside | 16 |17 | |
|---|---|---|
| {{ snackMachine.id }} | 23 |{{ snackMachine.moneyInside }} | 24 |25 | Show | 26 | Unload cash 27 | | 28 |
| ID | 40 |Cash | 41 |42 | |
|---|---|---|
| {{ atm.id }} | 48 |{{ atm.cash }} | 49 |50 | Show | 51 | Load Cash 52 | | 53 |
10 |
11 | ${{ snackPile.price|number_format(2) }}
12 | {{ snackPile.quantity }} left
13 |
24 | Money inserted: {{ snackMachine.moneyInTransactionAsString }} 25 |
26 | 31 | 36 |Money inside: {{ snackMachine.moneyInside }}
42 |
43 |
{{ snackMachine.moneyInside.oneCentCount }}
44 |
{{ snackMachine.moneyInside.tenCentCount }}
45 |
{{ snackMachine.moneyInside.quarterCount }}
46 |
48 |
{{ snackMachine.moneyInside.oneDollarCount }}
49 |
{{ snackMachine.moneyInside.fiveDollarCount }}
50 |
{{ snackMachine.moneyInside.twentyDollarCount }}
51 |