1. Go to this page and download the library: Download mikemix/tactician-module 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/ */
mikemix / tactician-module example snippets
// Real life example.
// Namespaces, imports, class properties skipped for brevity
class LoginController extends AbstractActionController
{
public function indexAction()
{
if ($this->request->isPost()) {
$this->form->setData($this->request->getPost());
if ($this->form->isValid()) {
$command = new UserLoginCommand(
$this->form->getLogin(),
$this->form->getPassword()
));
try {
$this->tacticianCommandBus($command);
return $this->redirect()->toRoute('home');
} catch (\Some\Kind\Of\Login\Failure $exception) {
$this->flashMessenger()->addErrorMessage($exception->getMessage());
return $this->redirect()->refresh();
}
}
}
$view = new ViewModel();
$view->setVariable('form', $this->form);
$view->setTemplate('app/login/index');
return $view;
}
}
final class UserLoginCommand
{
public function __construct($login, $password)
{
$this->login = $login;
$this->password = $password;
}
}
final class UserLoginHandler
{
// constructor skipped for brevity
public function handle(UserLoginCommand $command)
{
$this->authenticationService->login($command->username, $command->password);
}
}