PHP code example of victormln / laravel-tactician

1. Go to this page and download the library: Download victormln/laravel-tactician 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/ */

    

victormln / laravel-tactician example snippets


    'providers' => [
        ...
        Victormln\LaravelTactician\Providers\LaravelTacticianServiceProvider::class
        ...
    ]

    $bus = app('Victormln\LaravelTactician\CommandBusInterface');


    use Victormln\LaravelTactician\CommandBusInterface;

    class MyController extends BaseController
    {

        /** @var CommandBusInterface */
        private $bus;

        public function __construct(CommandBusInterface $bus)
        {
            $this->bus = $bus;
        }

    }


    // First parameter expects the command
    $bus->dispatch(new SimpleCommand());

    $bus->addHandler('Path\SimpleCommand', 'Path\SimpleCommandHandler');
    $bus->dispatch(new SimpleCommand());

    return [
        // The locator to bind
        'locator' => 'Victormln\LaravelTactician\Locator\LaravelLocator',
        // The inflector to bind
        'inflector' => 'League\Tactician\Handler\MethodNameInflector\HandleInflector',
        // The extractor to bind
        'extractor' => 'League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor',
        // The bus to bind
        'bus' => 'Victormln\LaravelTactician\Bus'
    ];
bash
    php artisan vendor:publish --provider="Victormln\LaravelTactician\Providers\LaravelTacticianServiceProvider"