An open API service indexing awesome lists of open source software.

https://github.com/clearcodehq/command-bus-console

CLI for command bus
https://github.com/clearcodehq/command-bus-console

Last synced: about 1 year ago
JSON representation

CLI for command bus

Awesome Lists containing this project

README

          

[![Build Status](https://travis-ci.org/ClearcodeHQ/command-bus-console.svg?branch=master)](https://travis-ci.org/ClearcodeHQ/command-bus-console)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ClearcodeHQ/command-bus-console/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ClearcodeHQ/command-bus-console/?branch=master)
[![MIT License](https://img.shields.io/packagist/l/clearcode/command-bus-console.svg)](https://github.com/ClearcodeHQ/command-bus-console/blob/master/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](https://github.com/matthiasnoback/symfony-console-form)
and [https://github.com/SimpleBus](https://github.com/SimpleBus).

# Installation

```console
$ composer require clearcode/command-bus-console
```

Enable bundles in the kernel of your Symfony application.

```php
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`.

```yaml
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

```console
$ 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

```console
$ 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.