Installation
The SDK relies on Composer to manage its dependencies. To install the SDK and add it as a dependency to an existing composer.json file:Usage
- US Region
- EU Region
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Connect a PHP application to Novu with the official server SDK to trigger workflows, manage subscribers, and send notifications from PHP code.
composer require "novuhq/novu"
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'<YOUR_SECRET_KEY_HERE>'
)
->build();
$triggerEventRequestDto = new Components\TriggerEventRequestDto(
workflowId: 'workflow_identifier',
to: new Components\SubscriberPayloadDto(
subscriberId: 'subscriber_unique_identifier',
firstName: 'Albert',
lastName: 'Einstein',
email: '[email protected]',
),
payload: [
'comment_id' => 'string',
'post' => [
'text' => 'string',
],
],
overrides: [
'email' => [
'bcc' => '[email protected]',
],
],
);
$response = $sdk->trigger(
triggerEventRequestDto: $triggerEventRequestDto,
idempotencyKey: '<value>'
);
if ($response->triggerEventResponseDto !== null) {
// handle response
}
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setServerURL('https://eu.api.novu.co')
->setSecurity(
'<YOUR_SECRET_KEY_HERE>'
)
->build();
$triggerEventRequestDto = new Components\TriggerEventRequestDto(
workflowId: 'workflow_identifier',
to: new Components\SubscriberPayloadDto(
subscriberId: 'subscriber_unique_identifier',
firstName: 'Albert',
lastName: 'Einstein',
email: '[email protected]',
),
payload: [
'comment_id' => 'string',
'post' => [
'text' => 'string',
],
],
overrides: [
'email' => [
'bcc' => '[email protected]',
],
],
);
$response = $sdk->trigger(
triggerEventRequestDto: $triggerEventRequestDto,
idempotencyKey: '<value>'
);
if ($response->triggerEventResponseDto !== null) {
// handle response
}
Was this page helpful?