项目作者: mmp4k

项目描述 :
Easy way to start your prooph project.
高级语言: PHP
项目地址: git://github.com/mmp4k/proophgen.git
创建时间: 2017-10-24T19:20:20Z
项目社区:https://github.com/mmp4k/proophgen

开源协议:

下载


proophgen

GitHub (Pre-)Release Date
Travis
Coveralls github
Packagist
GitHub release
Packagist
GitHub last commit

Why developers love CRUD? Because it’s easy to automate work around it. Why developers hate DDD/CQRS? Boilerplates.

Using this small app proophgen and single 15th lines yaml file you can generate a project that contains 48 files (with phpspec tests!) and start coding. No more boilerplates.

You can also use singe command to create your ValueObject, Command and AggregateRoot with Events.

Table of Contents

Examples

This is your yaml

  1. idPolicy: Ramsey\Uuid\UuidInterface # or string (default value)
  2. valueObjects:
  3. - Model\ValueObject\Mail
  4. - Model\ValueObject\Name
  5. - Model\ValueObject\Password
  6. commands:
  7. - Model\Command\RegisterUser
  8. - Model\Command\LoginUser
  9. aggregateRoots:
  10. Model\User:
  11. - !UserRegistered
  12. Model\Identity:
  13. - !EmailIdentityCreated
  14. - UserToIdentityAssigned
  15. - UserLogged

There is your command to run:

  1. $ proophgen do

And there is your result (since v0.1.10):

  1. ./src/Infrastructure/Identity/EventSourced.php 2042 21:06:28
  2. ./src/Infrastructure/Identity/InMemory.php
  3. ./src/Infrastructure/User/EventSourced.php
  4. ./src/Infrastructure/User/InMemory.php
  5. ./src/Model/Command/LoginUser.php
  6. ./src/Model/Command/RegisterUser.php
  7. ./src/Model/CommandHandler/LoginUserHandler.php
  8. ./src/Model/CommandHandler/RegisterUserHandler.php
  9. ./src/Model/Identity/Event/EmailIdentityCreated.php
  10. ./src/Model/Identity/Event/UserLogged.php
  11. ./src/Model/Identity/Event/UserToIdentityAssigned.php
  12. ./src/Model/Identity/Exception/IdentityNotFound.php
  13. ./src/Model/Identity/Guard/EmailIdentityCreatedGuard.php
  14. ./src/Model/Identity/Guard/UserLoggedGuard.php
  15. ./src/Model/Identity/Guard/UserToIdentityAssignedGuard.php
  16. ./src/Model/Identity.php
  17. ./src/Model/IdentityRepository.php
  18. ./src/Model/User/Event/UserRegistered.php
  19. ./src/Model/User/Exception/UserNotFound.php
  20. ./src/Model/User/Guard/UserRegisteredGuard.php
  21. ./src/Model/User.php
  22. ./src/Model/UserRepository.php
  23. ./src/Model/ValueObject/Mail.php
  24. ./src/Model/ValueObject/Name.php
  25. ./src/Model/ValueObject/Password.php
  26. ./spec/Infrastructure/Identity/EventSourcedSpec.php
  27. ./spec/Infrastructure/Identity/InMemorySpec.php
  28. ./spec/Infrastructure/User/EventSourcedSpec.php
  29. ./spec/Infrastructure/User/InMemorySpec.php
  30. ./spec/Model/Command/LoginUserSpec.php
  31. ./spec/Model/Command/RegisterUserSpec.php
  32. ./spec/Model/CommandHandler/LoginUserHandlerSpec.php
  33. ./spec/Model/CommandHandler/RegisterUserHandlerSpec.php
  34. ./spec/Model/Identity/Event/EmailIdentityCreatedSpec.php
  35. ./spec/Model/Identity/Event/UserLoggedSpec.php
  36. ./spec/Model/Identity/Event/UserToIdentityAssignedSpec.php
  37. ./spec/Model/Identity/Exception/IdentityNotFoundSpec.php
  38. ./spec/Model/Identity/Guard/EmailIdentityCreatedGuardSpec.php
  39. ./spec/Model/Identity/Guard/UserLoggedGuardSpec.php
  40. ./spec/Model/Identity/Guard/UserToIdentityAssignedGuardSpec.php
  41. ./spec/Model/IdentitySpec.php
  42. ./spec/Model/User/Event/UserRegisteredSpec.php
  43. ./spec/Model/User/Exception/UserNotFoundSpec.php
  44. ./spec/Model/User/Guard/UserRegisteredGuardSpec.php
  45. ./spec/Model/UserSpec.php
  46. ./spec/Model/ValueObject/MailSpec.php
  47. ./spec/Model/ValueObject/NameSpec.php
  48. ./spec/Model/ValueObject/PasswordSpec.php

Create single ValueObject

You need to run that command:

  1. proophgen vo Model/ValueObject/FirstName

As a result you should to see something similar to:

  1. Creating files:
  2. [v] ./src/Model/ValueObject/FirstName.php
  3. [v] ./spec/Model/ValueObject/FirstNameSpec.php

Create single Command

You need to run that command:

  1. proophgen c Model/Command/RemoveUser

As a result you should to see something similar to:

  1. Creating files:
  2. [v] ./src/Model/Command/RemoveUser.php
  3. [v] ./src/Model/CommandHandler/RemoveUserHandler.php
  4. [v] ./spec/Model/Command/RemoveUserSpec.php
  5. [v] ./spec/Model/CommandHandler/RemoveUserHandlerSpec.php

Create single AggregateRoot with Events

You need to run that command:

  1. proophgen ar Model/Admin \!AdminCreated AdminRemoved AdminBlocked

As a result you should to see something similar to:

  1. Creating files:
  2. [v] ./src/Model/Admin.php
  3. [v] ./src/Model/AdminRepository.php
  4. [v] ./src/Model/Admin/Exception/AdminNotFound.php
  5. [v] ./src/Model/Admin/Event/AdminCreated.php
  6. [v] ./src/Model/Admin/Guard/AdminCreatedGuard.php
  7. [v] ./src/Model/Admin/Event/AdminRemoved.php
  8. [v] ./src/Model/Admin/Guard/AdminRemovedGuard.php
  9. [v] ./src/Model/Admin/Event/AdminBlocked.php
  10. [v] ./src/Model/Admin/Guard/AdminBlockedGuard.php
  11. [v] ./src/Infrastructure/Admin/InMemory.php
  12. [v] ./src/Infrastructure/Admin/EventSourced.php
  13. [v] ./spec/Model/AdminSpec.php
  14. [v] ./spec/Infrastructure/Admin/EventSourcedSpec.php
  15. [v] ./spec/Model/Admin/Exception/AdminNotFoundSpec.php
  16. [v] ./spec/Infrastructure/Admin/InMemorySpec.php
  17. [v] ./spec/Model/Admin/Event/AdminCreatedSpec.php
  18. [v] ./spec/Model/Admin/Guard/AdminCreatedGuardSpec.php
  19. [v] ./spec/Model/Admin/Event/AdminRemovedSpec.php
  20. [v] ./spec/Model/Admin/Guard/AdminRemovedGuardSpec.php
  21. [v] ./spec/Model/Admin/Event/AdminBlockedSpec.php
  22. [v] ./spec/Model/Admin/Guard/AdminBlockedGuardSpec.php

Id Policy

As default proophgen generates all ids as string. If you wish you can change it just running this variant of previous commands:

For aggregate root:

  1. proophgen ar --id-policy="Ramsey\Uuid\UuidInterface" Model/Admin \!AdminCreated AdminRemoved AdminBlocked

For command:

  1. proophgen c --id-policy="Ramsey\Uuid\UuidInterface" Model/Command/RemoveUser

Installation

There is a few way to use proophgen

1. You can download .phar file

Go to releases page on github and download proophgen.phar.

  1. mv ~/Downloads/proophgen.phar /usr/local/bin/proophgen
  2. chmod +x /usr/local/bin/proophgen

2. You can use docker

Just run that command:

  1. docker run -v $(pwd):/var/www proophgen/proophgen

You can add proophgen directly to your project as dev dependency but then your project and proophgen will be sharing a whole dependencies and some conflicts can happened.

  1. composer require --dev pilsniak/proophgen