EventBridge client

This page contains examples with the EventBridge client. See the client introduction for a more detailed description how to use a client. You may also want to consider the authentication documentation to understand the many ways you can authenticate with AWS.

The EventBridge package could be installed with Composer.

composer require async-aws/event-bridge

A new client object may be instantiated by:

use AsyncAws\EventBridge\EventBridgeClient; $eventBridge = new EventBridgeClient();

The authentication parameters is read from the environment by default. You can also specify a AWS access id and secret:

use AsyncAws\EventBridge\EventBridgeClient; $eventBridge = new EventBridgeClient([ 'accessKeyId' => 'my_access_key', 'accessKeySecret' => 'my_access_secret', 'region' => 'eu-central-1', ]);

For all available options, see the configuration reference.


Sends custom events

use AsyncAws\EventBridge\EventBridgeClient; use AsyncAws\EventBridge\Input\PutEventsRequest; use AsyncAws\EventBridge\ValueObject\PutEventsRequestEntry; $eventBridge = new EventBridgeClient(); $events = $eventBridge->putEvents(new PutEventsRequest([ 'Entries' => [ new PutEventsRequestEntry([ 'EventBusName' => 'arn:aws:events:region:account:event-bus/event-bus-name', 'Source' => 'acme.newsletter.campaign', 'DetailType' => 'UserSignUp', 'Detail' => json_encode(['email' => $userEmail]), ]) ], ])); echo 'Sent '. count($events->getEntries()) . ' events, with ' . $events->getFailedEntryCount() . ' failures';

The source code to this page is found on GitHub.