albertoarena/laravel-event-sourcing-generator
最新稳定版本:v1.0.12
Composer 安装命令:
composer require albertoarena/laravel-event-sourcing-generator
包简介
Laravel event sourcing domain generator
README 文档
README
Laravel event sourcing generator adds a new Artisan command that can generate a full domain directory structure for Spatie event sourcing.
Table of Contents
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Feel free to fork, improve and create a pull request.
Please see CONTRIBUTING for details.
Installation
Compatibility
| What | Version |
|---|---|
| PHP | 8.2 / 8.3 |
| Laravel | 10.x / 11.x (*) |
| Spatie's event sourcing | 7.x |
(*) Package has been tested in Laravel 10, even it is not officially released for that version.
Install
composer require albertoarena/laravel-event-sourcing-generator
Usage
php artisan make:event-sourcing-domain <model>
[-d|--domain=<domain>] # The name of the domain
[--namespace=<namespace>] # The namespace or root folder (default: "Domain")
[-m|--migration=<existing_migration>] # Indicate any existing migration for the model, with or without timestamp prefix. Table name is sufficient
[--migration-exclude=<excluded_migration>] # Indicate any existing migration for the model, that must be excluded. It accepts regex. Table name is sufficient
[-a|--aggregate=<0|1>] # Indicate if aggregate must be created or not (accepts 0 or 1)
[-r|--reactor=<0|1>] # Indicate if reactor must be created or not (accepts 0 or 1)
[-u|--unit-test] # Indicate if PHPUnit tests must be created
[-p|--primary-key=<uuid|id>] # Indicate which is the primary key (uuid, id)
[--indentation=<indent>] # Indentation spaces
[--failed-events=<0|1>] # Indicate if failed events must be created (accepts 0 or 1)
[--notifications=<database,mail,no,slack,teams>] # Indicate if notifications must be created, comma separated (accepts database,mail,no,slack,teams)
[--root=<root> # The name of the root folder (default: "app")
Show help
php artisan help make:event-sourcing-domain
Basic usage
Documentation about basic usage
Generate a model with same name of the domain
php artisan make:event-sourcing-domain Animal \ --domain=Animal
Generate a model with different domain
Read documentation with examples
php artisan make:event-sourcing-domain Tiger \ --domain=Animal
Generate a model with different domain and namespace
Read documentation with examples
php artisan make:event-sourcing-domain Tiger \ --domain=Animal \ --namespace=CustomDomain
Generate a model from existing migration
Read documentation with examples
php artisan make:event-sourcing-domain Animal \ --migration=create_animal_table \ --unit-test
Generate a model from existing migration using pattern and exclude specific one
Read documentation with examples
php artisan make:event-sourcing-domain Animal \ --migration=animal \ --migration-exclude=drop_last_column_from_animals \ --unit-test
Generate a model from existing migration using pattern and exclude using regex
Read documentation with examples
php artisan make:event-sourcing-domain Animal \
--migration=animal \
--migration-exclude="/drop_.*_from_animals/" \
--unit-test
Generate a model from existing migration with PHPUnit tests
php artisan make:event-sourcing-domain Animal \ --migration=create_animal_table \ --unit-test
Generate a model from existing migration with failed events and database / mail / Slack notifications
php artisan make:event-sourcing-domain Animal \ --migration=create_animal_table \ --failed-events=1 \ --notifications=database,mail,slack
Domain and namespace
Read documentation about directory structure
Specify the name of the domain
Read documentation with examples
php artisan make:event-sourcing-domain Animal --domain=Tiger php artisan make:event-sourcing-domain Animal --domain=Lion
Specify the namespace
Read documentation with examples
php artisan make:event-sourcing-domain Tiger --namespace=MyDomain --domain=Animal
Advanced usage
Set primary key
Read documentation with examples
Default primary key is uuid. That will work with Aggregate class.
It is possible to use id as primary key:
php artisan make:event-sourcing-domain Animal --primary-key=id
When importing migrations, primary key will be automatically loaded from file.
Generate PHPUnit tests
Read documentation with examples
php artisan make:event-sourcing-domain Animal --unit-test
Generate aggregates
Read documentation with examples
php artisan make:event-sourcing-domain Animal --aggregate=1
This is available only for models using uuid as primary key.
Generate reactors
Read documentation with examples
php artisan make:event-sourcing-domain Animal --reactor=1
Generate failed events
Read documentation with examples
php artisan make:event-sourcing-domain Animal --failed-events=1
Generate notifications
Read documentation with examples
php artisan make:event-sourcing-domain Animal --notifications=<NOTIFICATIONS>
Specify indentation
Read documentation with examples
php artisan make:event-sourcing-domain Animal --indentation=2
Specify the path of root folder
Read documentation with examples
php artisan make:event-sourcing-domain Animal --root=src
Limitations and future enhancements
Blueprint column types
统计信息
- 总下载量: 6.7k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-25