2amigos / command-bus
Simple Command Bus
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
pkg:composer/2amigos/command-bus
Requires
- php: >=5.5.0
- psr/log: ^1.0
Requires (Dev)
- fabpot/php-cs-fixer: @stable
- phpmd/phpmd: @stable
- phpunit/phpunit: 5.*
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2023-08-16 03:06:49 UTC
README
NOTE: This library still under development (tests are not yet included). Use it at your own risk.
A very simple Command Bus to plug into your project. This library differs from other similar libraries like Tactician and SimpleBus not on its purpose but on the approach taken.
Bus has been inspired by both of those libraries but it moves away from the Command > CommandHandler terminology
due to the function of a Command object. The object in other libraries work as a mere data object, and that IMO is
what a Message should be, I understand Command should execute or process a Message, getting the data that
requires to be executed from it. So, this library has the following characteristics:
- It handles
Messageinstances - Every
Messageis processed by exactly oneCommand - The library is extensible by
strategies. Currently supportingExecuteStrategy(simple locate and execute), andMiddlewareStrategy(supporting middleware pattern). Newstrategiescan be easily implemented. - The behavior of the
MiddlewareStrategyis also extensible. Newmiddlewarescan be added to themiddleware strategy, somessagescan be handled the way you wish. Middlewares do things before (seeLockingMiddleware) and/or after (seeLogginMiddleware) handling a command.
Examples
- TODO
Clean code
We have added some development tools for you to contribute to the library with clean code:
- PHP mess detector: Takes a given PHP source code base and look for several potential problems within that source.
- PHP code sniffer: Tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
- PHP code fixer: Analyzes some PHP source code and tries to fix coding standards issues.
And you should use them in that order.
Using php mess detector
Sample with all options available:
./vendor/bin/phpmd ./src text codesize,unusedcode,naming,design,controversial,cleancode
Using code sniffer
./vendor/bin/phpcs -s --report=source --standard=PSR2 ./src
Using code fixer
We have added a PHP code fixer to standardize our code. It includes Symfony, PSR2 and some contributors rules.
./vendor/bin/php-cs-fixer --config-file=.php_cs fix ./src
Testing
$ ./vendor/bin/phpunit
Custom Software | Web & Mobile Software Development
www.2amigos.us