2017 © Pedro Peláez
 

application proophgen

image

pilsniak/proophgen

  • Saturday, November 4, 2017
  • by mmp4k
  • Repository
  • 2 Watchers
  • 6 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

proophgen

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

Why developers love CRUD? Because it's easy to automate work around it. Why developers hate DDD/CQRS? Boilerplates., (*2)

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., (*3)

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

Table of Contents

Examples

This is your yaml, (*5)

idPolicy: Ramsey\Uuid\UuidInterface # or string (default value)
valueObjects:
  - Model\ValueObject\Mail
  - Model\ValueObject\Name
  - Model\ValueObject\Password
commands:
  - Model\Command\RegisterUser
  - Model\Command\LoginUser
aggregateRoots:
  Model\User:
    - !UserRegistered
  Model\Identity:
    - !EmailIdentityCreated
    - UserToIdentityAssigned
    - UserLogged

There is your command to run:, (*6)

$ proophgen do

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

./src/Infrastructure/Identity/EventSourced.php                                                                                                      ✔  2042  21:06:28 
./src/Infrastructure/Identity/InMemory.php
./src/Infrastructure/User/EventSourced.php
./src/Infrastructure/User/InMemory.php
./src/Model/Command/LoginUser.php
./src/Model/Command/RegisterUser.php
./src/Model/CommandHandler/LoginUserHandler.php
./src/Model/CommandHandler/RegisterUserHandler.php
./src/Model/Identity/Event/EmailIdentityCreated.php
./src/Model/Identity/Event/UserLogged.php
./src/Model/Identity/Event/UserToIdentityAssigned.php
./src/Model/Identity/Exception/IdentityNotFound.php
./src/Model/Identity/Guard/EmailIdentityCreatedGuard.php
./src/Model/Identity/Guard/UserLoggedGuard.php
./src/Model/Identity/Guard/UserToIdentityAssignedGuard.php
./src/Model/Identity.php
./src/Model/IdentityRepository.php
./src/Model/User/Event/UserRegistered.php
./src/Model/User/Exception/UserNotFound.php
./src/Model/User/Guard/UserRegisteredGuard.php
./src/Model/User.php
./src/Model/UserRepository.php
./src/Model/ValueObject/Mail.php
./src/Model/ValueObject/Name.php
./src/Model/ValueObject/Password.php
./spec/Infrastructure/Identity/EventSourcedSpec.php
./spec/Infrastructure/Identity/InMemorySpec.php
./spec/Infrastructure/User/EventSourcedSpec.php
./spec/Infrastructure/User/InMemorySpec.php
./spec/Model/Command/LoginUserSpec.php
./spec/Model/Command/RegisterUserSpec.php
./spec/Model/CommandHandler/LoginUserHandlerSpec.php
./spec/Model/CommandHandler/RegisterUserHandlerSpec.php
./spec/Model/Identity/Event/EmailIdentityCreatedSpec.php
./spec/Model/Identity/Event/UserLoggedSpec.php
./spec/Model/Identity/Event/UserToIdentityAssignedSpec.php
./spec/Model/Identity/Exception/IdentityNotFoundSpec.php
./spec/Model/Identity/Guard/EmailIdentityCreatedGuardSpec.php
./spec/Model/Identity/Guard/UserLoggedGuardSpec.php
./spec/Model/Identity/Guard/UserToIdentityAssignedGuardSpec.php
./spec/Model/IdentitySpec.php
./spec/Model/User/Event/UserRegisteredSpec.php
./spec/Model/User/Exception/UserNotFoundSpec.php
./spec/Model/User/Guard/UserRegisteredGuardSpec.php
./spec/Model/UserSpec.php
./spec/Model/ValueObject/MailSpec.php
./spec/Model/ValueObject/NameSpec.php
./spec/Model/ValueObject/PasswordSpec.php

Create single ValueObject

You need to run that command:, (*8)

proophgen vo Model/ValueObject/FirstName

As a result you should to see something similar to:, (*9)

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

Create single Command

You need to run that command:, (*10)

proophgen c Model/Command/RemoveUser 

As a result you should to see something similar to:, (*11)

Creating files:
[v] ./src/Model/Command/RemoveUser.php
[v] ./src/Model/CommandHandler/RemoveUserHandler.php
[v] ./spec/Model/Command/RemoveUserSpec.php
[v] ./spec/Model/CommandHandler/RemoveUserHandlerSpec.php

Create single AggregateRoot with Events

You need to run that command:, (*12)

proophgen ar Model/Admin \!AdminCreated AdminRemoved AdminBlocked  

As a result you should to see something similar to:, (*13)

Creating files:
[v] ./src/Model/Admin.php
[v] ./src/Model/AdminRepository.php
[v] ./src/Model/Admin/Exception/AdminNotFound.php
[v] ./src/Model/Admin/Event/AdminCreated.php
[v] ./src/Model/Admin/Guard/AdminCreatedGuard.php
[v] ./src/Model/Admin/Event/AdminRemoved.php
[v] ./src/Model/Admin/Guard/AdminRemovedGuard.php
[v] ./src/Model/Admin/Event/AdminBlocked.php
[v] ./src/Model/Admin/Guard/AdminBlockedGuard.php
[v] ./src/Infrastructure/Admin/InMemory.php
[v] ./src/Infrastructure/Admin/EventSourced.php
[v] ./spec/Model/AdminSpec.php
[v] ./spec/Infrastructure/Admin/EventSourcedSpec.php
[v] ./spec/Model/Admin/Exception/AdminNotFoundSpec.php
[v] ./spec/Infrastructure/Admin/InMemorySpec.php
[v] ./spec/Model/Admin/Event/AdminCreatedSpec.php
[v] ./spec/Model/Admin/Guard/AdminCreatedGuardSpec.php
[v] ./spec/Model/Admin/Event/AdminRemovedSpec.php
[v] ./spec/Model/Admin/Guard/AdminRemovedGuardSpec.php
[v] ./spec/Model/Admin/Event/AdminBlockedSpec.php
[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:, (*14)

For aggregate root:, (*15)

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

For command:, (*16)

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

Installation

There is a few way to use proophgen, (*17)

1. You can download .phar file

Go to releases page on github and download proophgen.phar., (*18)

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

2. You can use docker

Just run that command:, (*19)

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., (*20)

composer require --dev pilsniak/proophgen

The Versions