Download the PHP package skillberto/command-handler without Composer
On this page you can find all versions of the php package skillberto/command-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download skillberto/command-handler
More information about skillberto/command-handler
Files in skillberto/command-handler
Package command-handler
Short Description Simple isolated command handler library.
License MIT
Informations about the package command-handler
Command Handler
Install
Install from composer:
Authors and contributors
- Norbert Heiszler (Creator, developer)
Usage
The following example show you how you can us it:
You can define collections too:
If you want to skip a command if it's not required:
...after that you can get these commands:
But, if you don't skip a command, and it's not successful:
Advanced usage
Prefix
The following example show you have can you use the prefix:
In this case, you will execute .
Timeout
It can be defined for each command, or only for some commands, or both of them.
In the previous example every command will have "0.2 seconds" for execution, except , it has got "0.3 seconds".
Let's see how can you define group timeout:
In this example the first collection have "0.2 seconds", the second "0.3 seconds".
Handler injection, merge
In some case, we need to define more then one handler, eg.: for different prefixes. But don't worry about it, we have got a useful method:
It's good, but what will be with prefixes and timeout? For these problems, CommandHandler has got three different merge types:
The default is , but you can change it:
In the previous example prefix merge has got type, timeout has got type. means that prefix / timeout will use for all of them. means that prefix / timeout will use, if it's not defined for command(s). means that prefixes and timeouts will be separated.
Callback
You can define a callback for each execution: