1. Go to this page and download the library: Download league/tactician-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
league / tactician-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new League\Tactician\Bundle\TacticianBundle(),
);
// ...
}
// ...
}
namespace AppBundle\Controller;
use League\Tactician\CommandBus;
use AppBundle\Commands\DoSomethingCommand;
class YourNameController
{
private $commandBus;
public function __construct(CommandBus $commandBus)
{
$this->commandBus = $commandBus;
}
public function doSomething()
{
$command = new DoSomethingCommand();
$this->commandBus->handle($command);
}
}
namespace AppBundle\Controller;
use League\Tactician\CommandBus;
use AppBundle\Commands\DoSomethingCommand;
class YourNameController
{
public function doSomething(CommandBus $commandBus)
{
$command = new DoSomethingCommand();
$commandBus->handle($command);
}
}
namespace AppBundle\Controller;
use League\Tactician\CommandBus;
class YourNameController
{
public function doSomething(CommandBus $defaultBus)
{
//
}
}
class RegisterUserHandler
{
public function handle(RegisterUser $command)
{
// do stuff
}
}
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new League\Tactician\Bundle\TacticianBundle(
new My\Custom\HandlerMapping()
),
);
}
}
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new League\Tactician\Bundle\TacticianBundle(
new League\Tactician\Bundle\DependencyInjection\HandlerMapping\CompositeMapping(
new League\Tactician\Bundle\DependencyInjection\HandlerMapping\ClassNameMapping(), // standard command: "FQCN" mapping
new League\Tactician\Bundle\DependencyInjection\HandlerMapping\TypeHintMapping(), // standard typehints: true mapping
new My\Custom\HandlerMapping() // your custom routing
)
),
);
}
}