romaindesajardim/broadway-generator-bundle
Composer 安装命令:
composer require romaindesajardim/broadway-generator-bundle
包简介
This bundle generates code for you
README 文档
README
BroadwayGeneratorBundle
This bundle gives some symfony commands to generate Commands, Events, ReadModels, and more, for Broadway.
This bundle is highly inspired by SensioGeneratorBundle
Installation
Install it with composer
composer require romaindesajardim/broadway-generator-bundle
and add it to your AppKernel.php
new RomainDeSaJardim\Bundle\BroadwayGeneratorBundle\BroadwayGeneratorBundle(),
Features
Actually there is only one command available. More will come soon ...
Broadway Commands
This command generate a Broadway command and implements the handle method in the Broadway Command Handler automatically. You have just to add your parameters and code the handler.
php bin/console rdsj:broadway:generate-command
⚠️ If you use Symfony 2, use app/console instead of bin/console
This command need 3 inputs :
bundle(The bundle name where the Broadway Command will be generate)name(The name of the Broadway Command you want)command-handlerOptionnal (The Command Handler's service id where the Broadway Command will be handle)
By default the command is run in the interactive mode and asks questions to determine values of thoose inputs
But if you want, you can run the command in a non-interactive mode and providing the needed inputs
php bin/console rdsj:broadway:generate-command --no-interaction FooBarBundle FooBar [foo.bar-handler]
Exemple
Imagine I have my Broadway Command Handler FooBarBundle\FooBarCommandHandler linked by a Symfony service :
<service id="foo.bar.command_handler" class="FooBarBundle\FooBarCommandHandler">
<tag name="command_handler"/>
</service>
And I want to create a Broadway Command FooBar in the same bundle as my Command Handler FooBarBundle
So in a non interactive mode I have to launch this command :
php bin/console rdsj:broadway:generate-command --no-interaction FooBarBundle FooBar foo.bar.command_handler
The result will be :
A new file Command\FooBarCommand.php
<?php
namespace FooBarBundle\Command;
class FooBarCommand
{
private $uuid;
public function __construct($uuid)
{
$this->uuid = $uuid;
}
public function getUUID()
{
return $this->uuid;
}
}
And a new handle method a the end of my Command Handler FooBarCommandHandler.php
public function handleFooBar(FooBarCommand $command)
{
// @TODO Insert your code here
}
Broadway Events
This command generate a Broadway event and implements the handle method in the Broadway Projector automatically. You have just to add your parameters and code the handler.
php bin/console rdsj:broadway:generate-event
⚠️ If you use Symfony 2, use app/console instead of bin/console
This command need 3 inputs :
bundle(The bundle name where the Broadway Command will be generate)name(The name of the Broadway Command you want)projectorOptionnal (The Projector's service id where the Broadway Event will be handle)
By default the command is run in the interactive mode and asks questions to determine values of thoose inputs
But if you want, you can run the command in a non-interactive mode and providing the needed inputs
php bin/console rdsj:broadway:generate-command --no-interaction FooBarBundle FooBar [foo.bar-projector]
Exemple
Same as Broadway Commands' one
Broadway ReadModel's
This command generate a Broadway ReadModel and add it to the service configuration of you're bundle. You have just to add your parameters and code the ReadModel.
php bin/console rdsj:broadway:generate-readmodel
⚠️ If you use Symfony 2, use app/console instead of bin/console
This command need 3 inputs :
bundle(The bundle name where the Broadway Command will be generate)name(The name of the Broadway Command you want)service-filenameOptionnal _(The service filename is the name of the file where your bundle services are configurated)
By default the command is run in the interactive mode and asks questions to determine values of thoose inputs
But if you want, you can run the command in a non-interactive mode and providing the needed inputs
php bin/console rdsj:broadway:generate-readmodel --no-interaction FooBarBundle FooBar [services.xml]
Exemple
php bin/console rdsj:broadway:generate-readmodel --no interaction FooBarBundle FooBar services.xml
This command generate a ReadModel like this.
<?php
namespace FooBarBundle\ReadModel;
use Broadway\ReadModel\Identifiable;
class FooBarReadModel implements Identifiable
{
private $id;
public function __construct($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
}
and transform service.xml
<?xml version="1.0"?>
<response xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="false"/>
</services>
</response>
in
<?xml version="1.0"?>
<response xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="false"/>
<service id="toto.readmodel" class="Broadway\ReadModel\ReadModel">
<factory method="create" service="broadway.read_model.repository_factory"/>
<argument>toto.readmodel</argument>
<argument>AppBundle\ReadModel\TotoReadModel</argument>
</service>
</services>
</response>
in order to configure the new ReadModel service
TODO
- Add a command to apply or handle an event in a projector, processor or saga
- Add a command to generate Broadway Event
- Add a command to generate Broadway ReadModel
- Add a command to generate Broadway Command Handler
- Generate Command handler automatically if it doesn't exist on Broadway Command creation
- Add fields to Broadway Command to add fields and implements getters
Reporting an issue or a feature request
You feel free to report a new issue or a feature requests if it doesn't already exist or is in the Todo list (for feature request)
Contribute
You feel free to open pull request
romaindesajardim/broadway-generator-bundle 适用场景与选型建议
romaindesajardim/broadway-generator-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 10 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「bundle」 「broadway」 「BroadwayBundle」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 romaindesajardim/broadway-generator-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 romaindesajardim/broadway-generator-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 romaindesajardim/broadway-generator-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Serialization helpers for Broadway
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
A Laravel adapter for the Broadway ES/CQRS package.
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-24