2017 © Pedro Peláez
 

library tactician-adapter

League tactician command bus adapter for zend-expressive framework.

image

infw/tactician-adapter

League tactician command bus adapter for zend-expressive framework.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Zend-expressive Tactician adapter

Scrutinizer Code Quality Build Status SensioLabsInsight, (*1)

League tactician command bus adapter for zend-expressive framework., (*2)

!!!! This package is not more mantained in favor of https://github.com/antidot-framework/tactician-adapter, (*3)

Getting started

Installation

composer require infw/tactician-adapter

You can activate using Zend config-manager in a expressive modular application., (*4)

Config

Create command-bus.global.php file inner config autoload directory., (*5)

<?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., (*6)

<?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., (*7)

<?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., (*8)

This is default config., (*9)

<?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,

        ],
    ],
];

The Versions