PHP code example of sobi-labs / frameflow

1. Go to this page and download the library: Download sobi-labs/frameflow 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/ */

    

sobi-labs / frameflow example snippets


use FrameFlow\Message;
use FrameFlow\Encoder;

// 1. Create a message with global metadata
$message = Message::make();
$message->header->meta->add('Environment', 'Production');

// 2. Add frames (can be simple strings or Frame objects)
$message->add("This is the first part of my data.");
$message->add("And here is more content...");

$id = uniqid();
$frame = new Message\Frame($message->header, $id, 'notification', new Message\Meta([
    "Content-Type" => "text/html; charset=utf-8",
    "Action" => "ShowAlert",
]));
$frame->payload = "<div>At least an HTML content</div>";
$message->add($frame);

// 3. Encode to streamable string
echo Encoder::encode($message);

$frame = $message->get($id);
echo $frame->size;     // Returns byte length
echo $frame->checksum; // Returns current hash of payload