PHP code example of icanboogie / bind-message-bus

1. Go to this page and download the library: Download icanboogie/bind-message-bus 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/ */

    

icanboogie / bind-message-bus example snippets




use ICanBoogie\MessageBus\SimpleDispatcher;

/* @var \ICanBoogie\Application $app */

$bus = new SimpleDispatcher($app->message_handler_provider);
# or
$bus = $app->message_bus;



/* @var \ICanBoogie\Application $app */

$app->message_bus;
$app->message_handler_provider;



use ICanBoogie\Routing\Controller;

class ProductController extends Controller
{
    use Controller\ActionTrait;
    use \ICanBoogie\Binding\MessageBus\ControllerBindings;

    protected function action_create()
    {
        $message = new CreateProduct($this->request['payload']);
        $result = $this->dispatch_message($message);

        return $this->respond($result);
    }
}



namespace App\Application\Message;

use function ICanBoogie\Service\ref;
use ICanBoogie\Binding\MessageBus\MessageBusConfig;

return [

    MessageBusConfig::HANDLERS => [

        CreateArticle::class => ref('handler.article.create'),
        DeleteArticle::class => ref('handler.article.delete'),

    ]

];