1. Go to this page and download the library: Download zelenin/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/ */
zelenin / message-bus example snippets
$handlers = [
CreatePost::class => new CreatePostHandler($postRepository)
];
$middlewares = [
new HandlerMiddleware(new MemoryLocator($handlers))
];
$commandBus = new MiddlewareBus(new MiddlewareStack($middlewares));
$message = new CreatePost('Post title', 'Post content');
$context = $commandBus->handle($message);
$provider = new AnnotationProvider(__DIR__ . '/src');
if ($isProduction) {
$provider = new CacheProvider(__DIR__ . '/data/handlers-cache.php', $provider);
}
$locator = new ProviderLocator($provider, new ContainerHandlerResolver($container));
return new MiddlewareBus(new MiddlewareStack([
new HandlerMiddleware($locator),
]));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.