dafiti / messagebus
messagebus
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 7 505
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 20
Forks: 0
Open Issues: 0
Requires
- aws/aws-sdk-php: 3.18.28
- symfony/event-dispatcher: 3.*
Requires (Dev)
- phpunit/phpunit: ^6
This package is not auto-updated.
Last update: 2021-06-19 17:14:35 UTC
README
Send event messages using AWS SNS
Instalation
Add:
"dafiti/messagebus": "dev-master"
To your composer.json
or Run:
composer require dafiti/messagebus
Usage
<?php use Aws\Kinesis\KinesisClient; use Dafiti\MessageBus\Config; use Dafiti\MessageBus\Dispatcher\Adapter\Kinesis; use Dafiti\MessageBus\Dispatcher\Dispatcher; use Dafiti\MessageBus\Entity\Order\OrderEntity; use Dafiti\MessageBus\Events\EventCollection; use Dafiti\MessageBus\Events\Order\CreateOrder; use Dafiti\MessageBus\MessageBus; require __DIR__ . "/../vendor/autoload.php"; // Create library configuration $config = new Config(Config::ENV_LOCAL, 'fake-steeam-name', 'fake-sender', 'partition-key'); // Initialize dispatcher adapter $kinesisClient = new KinesisClient([ 'profile' => 'default', 'region' => 'us-east-1', 'version' => 'latest', ]); $adapter = new Kinesis($kinesisClient, $config); // Create dispatcher $dispatcher = new Dispatcher($adapter); // Create the main object $messageBus = new MessageBus($dispatcher, $config); // Configure the event to be dispatched $order = new OrderEntity(...); $event = new CreateOrder($order); $messageBus->dispatch(new EventCollection([$event]));
This will send a message through the configurated adapter with the payload from the event that you created.