PHP code example of digiaonline / notification-wrapper

1. Go to this page and download the library: Download digiaonline/notification-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digiaonline / notification-wrapper example snippets


// Create a notification
$notification = new Notification('TYPE_FOO', ['id' => 1, 'name' => 'John']);

// Encode it as JSON (now you can send it somewhere)
$json = \json_encode($notification);

// Decode the notification on the other end
$notification = Notification::fromJson($json);

var_dump($notification->getType() === 'TYPE_FOO'); // true
var_dump($notification->getPayload() === ['id' => 1, 'name' => 'John']); // true