https://github.com/wyrihaximus/php-tactician-command-handler-mapper
Command to Handler mapper for Tactician
https://github.com/wyrihaximus/php-tactician-command-handler-mapper
command-bus hacktoberfest php tactician
Last synced: 6 months ago
JSON representation
Command to Handler mapper for Tactician
- Host: GitHub
- URL: https://github.com/wyrihaximus/php-tactician-command-handler-mapper
- Owner: WyriHaximus
- License: mit
- Created: 2016-08-28T17:55:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-05T05:31:21.000Z (over 2 years ago)
- Last Synced: 2025-04-09T23:38:43.947Z (about 1 year ago)
- Topics: command-bus, hacktoberfest, php, tactician
- Language: PHP
- Homepage:
- Size: 122 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Command to Handler mapper for [`Tactician`](http://tactician.thephpleague.com/)
[](https://travis-ci.org/wyrihaximus/php-tactician-command-handler-mapper)
[](https://packagist.org/packages/wyrihaximus/tactician-command-handler-mapper)
[](https://packagist.org/packages/wyrihaximus/tactician-command-handler-mapper/stats)
[](https://scrutinizer-ci.com/g/wyrihaximus/php-tactician-command-handler-mapper/?branch=master)
[](https://packagist.org/packages/wyrihaximus/tactician-command-handler-mapper)
[](https://travis-ci.org/wyrihaximus/php-tactician-command-handler-mapper)
# Install
To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.
```
composer require wyrihaximus/tactician-command-handler-mapper
```
# Set up
When creating a `Command` add the `@Handler` annotation to map it to a `Handler`.
```php
value = $value;
}
/**
* @return string
*/
public function getValue()
{
return $this->value;
}
}
```
# Mapping
The mapper needs a path where it can find commands. From there it scans all classes it finds for the `@Handler` annotation ad returns a map of commands and handlers that match.
## Mapper::mapInstantiated
For when you want to get started quickly and non of you handlers need to get dependencies injected.
```php
use League\Tactician\Setup\QuickStart;
use WyriHaximus\Tactician\CommandHandler\Mapper;
$commandBus = QuickStart::create(
Mapper::mapInstanciated('src' . DS . 'CommandBus')
);
```
## Mapper::map
For when you don't want a set instanciated handlers, for exampe useful when using [`league/tactician-container`](http://tactician.thephpleague.com/plugins/container/) for automatic dependency injection.
```php
use League\Tactician\Setup\QuickStart;
$commandToHandlerMap = Mapper::map('src' . DS . 'CommandBus');
```
# License
The MIT License (MIT)
Copyright (c) 2017 Cees-Jan Kiewiet
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.