Skip to main content
Novu’s PHP SDK provides simple, yet comprehensive notification management, and delivery capabilities through multiple channels that you can implement using code that integrates seamlessly with your PHP application. Explore the source code on GitHub

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:
composer require "novuhq/novu"

Usage

  • US Region
  • EU Region
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: 'albert@einstein.com',
    ),
    payload: [
        'comment_id' => 'string',
        'post' => [
            'text' => 'string',
        ],
    ],
    overrides: [
        'email' => [
            'bcc' => 'no-reply@novu.co',
        ],
    ],
);

$response = $sdk->trigger(
    triggerEventRequestDto: $triggerEventRequestDto,
    idempotencyKey: '<value>'

);

if ($response->triggerEventResponseDto !== null) {
    // handle response
}