PHP code example of tinymsg / msg

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

    

tinymsg / msg example snippets


// With Composer
oser

// Importing the namespace
use tinymsg\Msg;

// Server without SSL
$msg = new Msg('channel-name', 'tinymsg.domain.tld');

// Server with SSL
$msg = new Msg('channel-name', 'tinymsg.domain.tld', true);

// Localhost with special port
$msg = new Msg('channel-name', 'localhost:7777', false, 7777);

// Using the fully qualified namespace name
$msg = new tinymsg/Msg(...);

// Send a message
$msg->send('string');
$msg->send(array(1,2,3,4));
$msg->send(array('key' => 'value'));

// Close the socket connection
$msg->close();

// (Re-) Open the socket connection
$msg->open();