承接 clearcode/command-bus-console 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

clearcode/command-bus-console

Composer 安装命令:

composer require clearcode/command-bus-console

包简介

CLI for command bus.

README 文档

README

Build Status Scrutinizer Code Quality MIT License

Command Bus Console

Command Bus Console is a package exposing your command bus functionality to the CLI. Command Bus Console is based on Symfony Console Form and https://github.com/SimpleBus.

Installation

$ composer require clearcode/command-bus-console

Enable bundles in the kernel of your Symfony application.

    <?php
    // app/AppKernel.php

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new SimpleBusCommandBusBundle(), // this one you probably have already registered
            new SymfonyConsoleFormBundle(),
            new Clearcode\CommandBusConsole\Bundle\CommandBusConsoleBundle(),
        );
    }

Usage

Create and register form type for your command.

Assumed that you already have a command class and its handler class, create form type class mapping your command properties:

class SignUpType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('id', TextType::class, [
                'label' => 'Id',
            ])
            ->add('name', TextType::class, [
                'label' => 'Name',
            ])
            ->add('email', TextType::class, [
                'label' => 'email',
            ])
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults([
            'data_class' => SignUp::class,
        ]);
    }

    ...
}

And register your form type using command_bus.type with required attributes command which is FQCN of your command and alias which will be used to register console command with name command-bus:alias.

    form_type_service_id:
        class: Fully\Qualified\Class\Name\Of\SignUpType
        tags:
            - { name: form.type }
            - { name: command_bus.type, command: Fully\Qualified\Class\Name\Of\SignUp, alias: sign-up }

Run command in interactive mode

$ bin/console command-bus:sign-up
Id:
Name:
email:

[2015-12-11 10:34:55] The Fully\Qualified\Class\Name\Of\SignUp executed with success.

Run command in non interactive mode

$ bin/console command-bus:alias-for-command --no-interaction --id=1 --name=John --email=john@doe.com

[2015-12-11 10:34:55] The Fully\Qualified\Class\Name\Of\SignUp executed with success.

To Do

  • All fields should be required
  • Add generating form types on the fly
  • Add support for instantiating command objects via __construct
  • Add possibility to use any command bus implementation
  • Introduce abstraction on command bus

License

MIT, see LICENSE.

统计信息

  • 总下载量: 1.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 8
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固