Download the PHP package astrotechlabs/yii2-tactician without Composer
On this page you can find all versions of the php package astrotechlabs/yii2-tactician. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download astrotechlabs/yii2-tactician
More information about astrotechlabs/yii2-tactician
Files in astrotechlabs/yii2-tactician
Package yii2-tactician
Short Description Yii 2 Command Bus pattern implementation
License MIT
Homepage https://github.com/dersonsena/yii2-command-bus
Informations about the package yii2-tactician
Yii2 Tactician Command Bus
This is a Yii Framework 2 Wrapper/Adapter for Tactician Command Bus Library. It provides an easy way to use the command bus pattern in Yii2 Based apps.
When should I use Command Bus?
Tactician is a great fit if you’ve got a service layer. If you’re not sure what a service layer is, Martin Fowler’s PoEAA is a good starting point. Tactician’s author also did a talk on the subject.
Commands really help capture user intent. They’re also a great stand-in for the models when it comes to forms or serializer libraries that expect getter/setter objects.
The command bus itself is really easy to decorate with extra behaviors, like locking or database transactions so it’s very easy to extend with plugins.
By: tactician.thephpleague.com
When should I NOT use it?
If you’ve got a very small app that doesn’t need a service layer, then Tactician won’t offer much to you.
If you’re already using a tool that provides a command bus (like Broadway), you’re probably okay there too.
By: tactician.thephpleague.com
Installation
Setup
First you must have configure your Yii Dependency Injection Container to be able to use Command and Handler classes within it.
You should have something like this in your config/web.php
:
IMPORTANT: you must follow the conventions below:
- Your Command class must be suffixed by
Command
; - Your Handler class must be:
Same Command Class Name
+Without Command Suffix
+Handler
.
The last one is register Yii2TacticianCommandBus component in your config/web.php
file, as below:
How to Use
Mapping Command and Handler Classes
Define a Command
class somewhere in your application, for example:
Define your Handler
class should be something like:
Now we can use this command in controllers or wherever you want:
Using String Path
You can use a command class as String Path instead of concrete object. For this case, just do:
Your Handle Class should be as follows:
IMPORTANT: in this way your Handler Class MUST implements the AstrotechLabs\Yii2Tactician\Command.
Your controller action or anywhere else:
Under the hood the Command Bus System will call:
where $command
argument is created inside that like:
Enjoy =).
Authors
- Kilderson Sena - Owner - Yii Academy
See also the list of contributors who participated in this project.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Licence
This package is released under the MIT License. See the bundled LICENSE for details.
References
All versions of yii2-tactician with dependencies
league/tactician Version ^1.1
yiisoft/yii2 Version ~2.0.41
yidas/yii2-bower-asset Version ~2.0.13