infw / tactician-adapter
This package is abandoned and no longer maintained.
No replacement package was suggested.
League tactician command bus adapter for zend-expressive framework.
2.0.0
2019-02-25 10:55 UTC
Requires
- php: ^7.1
- league/tactician: ^1.0
- league/tactician-command-events: ^0.6.0
- league/tactician-container: ^1.0
- league/tactician-logger: ^0.10.0
- monolog/monolog: ^1.23
Requires (Dev)
- fetzi/phpspec-watcher: ^1.0
- memio/spec-gen: ^0.6.1
- phpspec/phpspec: ^3.0
- phpstan/phpstan: ^0.6.4
- phpunit/phpunit: ^5.7.21
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2020-10-07 15:40:37 UTC
README
League tactician command bus adapter for zend-expressive framework.
!!!! This package is not more mantained in favor of https://github.com/antidot-framework/tactician-adapter
Getting started
Installation
composer require infw/tactician-adapter
You can activate using Zend config-manager in a expressive modular application.
Config
Create command-bus.global.php
file inner config autoload directory.
<?php // command-bus.global.php return [ 'dependencies' => [ 'factories' => [ \Psr\Log\LoggerInterface => new Logger('app') // LoggerInterface is required, add your own logger instance. ] ], 'command-bus' => [ 'handler-map' => [ \App\Command\PingCommand::class => \App\Handler\PingHandler::class ], ], ];
Example command and handler.
<?php namespace App\Command; class PingCommand { }
<?php namespace App\Handler; use App\Command\PingCommand; class PingHandler { public function __invoke(PingCommand $command) { return time(); } }
You can use InFw\TacticianAdapter\Action\AbstractAction
as base action.
<?php namespace App\Action; use App\Command\PingCommand; use InFw\TacticianAdapter\Action\AbstractAction; use Interop\Http\ServerMiddleware\DelegateInterface; use Zend\Diactoros\Response\JsonResponse; use Psr\Http\Message\ServerRequestInterface; class PingAction extends AbstractAction { public function process(ServerRequestInterface $request, DelegateInterface $delegate) { return new JsonResponse(['ack' => $this->bus->handle(new PingCommand())]); } }
Modify Command Bus
You can modify the entire command bus to meet the needs of your project.
This is default config.
<?php return [ 'command-bus' => [ 'locator' => \League\Tactician\Handler\Locator\HandlerLocator::class, 'inflector' => \League\Tactician\Handler\MethodNameInflector\MethodNameInflector::class, 'extractor' => \League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor::class, 'formatter' => \League\Tactician\Logger\Formatter\Formatter::class, 'middleware' => [ \League\Tactician\Plugins\LockingMiddleware::class, \League\Tactician\Logger\LoggerMiddleware::class, \League\Tactician\CommandEvents\EventMiddleware::class, ], ], ];