1. Go to this page and download the library: Download rv/tproto 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/ */
rv / tproto example snippets
return new \Symfony\Component\HttpFoundation\StreamedResponse(function() use ($pdo) {
$tm = new \RV\TProto\Proto\Transmitter\Transmitter(function($data) {
echo $data;
}, null, true);
$pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
$res = $pdo->query("SELECT id, status FROM tblclients");
while (false !== ($row = $res->fetch(\PDO::FETCH_ASSOC))) {
$tm->send($row);
}
});
class Client
{
public $id;
public $status;
public function __construct($id, $status)
{
$this->id = $id;
$this->status = $status;
}
}
class CustomSerializer implements \RV\TProto\Serializer\SerializerInterface
{
public function serialize($data)
{
return $data['id'].";".$data['status'];
}
public function deserialize($data)
{
return new Client($data['id'], $data['status']);
}
public function getDelimiter()
{
return ":";
}
}
$update = new \RV\TProto\Proto\Receiver\Receiver($stream, function($data) {
var_dump($data);
}, new CustomSerializer());