docs/platform/sdks/server/php.mdx
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
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"
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 }
</Tab>
<Tab title="EU Region">
```php
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
}