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
- Host: GitHub
- URL: https://github.com/clearcodehq/command-bus-console
- Owner: ClearcodeHQ
- License: mit
- Created: 2015-10-26T10:56:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-15T10:43:40.000Z (over 10 years ago)
- Last Synced: 2025-03-30T13:37:08.517Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 0 Bytes
- Stars: 4
- Watchers: 9
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/ClearcodeHQ/command-bus-console)
[](https://scrutinizer-ci.com/g/ClearcodeHQ/command-bus-console/?branch=master)
[](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.