Bus
NOTE: This library still under development (tests are not yet included). Use it at your own risk., (*1)
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., (*2)
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:, (*3)
- It handles
Message
instances
- Every
Message
is processed by exactly one Command
- The library is extensible by
strategies
. Currently supporting ExecuteStrategy
(simple locate and execute), and
MiddlewareStrategy
(supporting middleware pattern). New strategies
can be easily implemented.
- The behavior of the
MiddlewareStrategy
is also extensible. New middlewares
can be added to the middleware
strategy
, so messages
can be handled the way you wish. Middlewares do things before (see LockingMiddleware
)
and/or after (see LogginMiddleware
) handling a command.
Examples
Clean code
We have added some development tools for you to contribute to the library with clean code:, (*4)
- 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., (*5)
Using php mess detector
Sample with all options available:, (*6)
./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., (*7)
./vendor/bin/php-cs-fixer --config-file=.php_cs fix ./src
Testing
bash
$ ./vendor/bin/phpunit
, (*8)
Custom Software | Web & Mobile Software Development
www.2amigos.us, (*9)