Skip to Content
๐ŸŽ‰ Bref 3.0 is released. Read more โ†’
DocumentationUse casesKinesis stream processing

Kinesis stream processing

To handle Kinesis eventsย , extend the KinesisHandler class:

use Bref\Context\Context; use Bref\Event\Kinesis\KinesisEvent; use Bref\Event\Kinesis\KinesisHandler; class MyHandler extends KinesisHandler { public function handleKinesis(KinesisEvent $event, Context $context): void { foreach ($event->getRecords() as $record) { $data = $record->getData(); // do something } } }

getData() decodes the record data as JSON and throws a JsonException if the data is not JSON. For other formats, use base64_decode($record->getRawData()).

Then, create a Lambda function that listens to the Kinesis stream with the handler you created:

serverless.yml
functions: # ... worker: handler: App\MyHandler runtime: php-84 events: - stream: type: kinesis arn: arn:aws:kinesis:eu-west-1:111111111111:stream/my-stream

The App\MyHandler class will be instantiated by Laravelโ€™s service container.

The stream event does not create the Kinesis stream. Learn more about using Kinesis in serverless.yml in the Serverless Framework documentationย .

Last updated on