1. Go to this page and download the library: Download knik/binn 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/ */
knik / binn example snippets
use Knik\Binn\Binn;
$binn = new Binn();
// List
$array = [123, -456, 789];
$binnString = $binn->serialize($array);
$unserialized = $binn->unserialize($binnString); // Equal with $array
$binn = new Binn();
$array = [ ["id" => 1, "name" => "John"], ["id" => 2, "name" => "Eric"] ]
// A list of objects
$binnString = $binn->serialize($array);
$unserialized = $binn->unserialize($binnString); // Equal with $array
$binn = new Binn();
$file = fopen('/path/to/file.jpg', 'rb');
// Filedata in binn structure
$bin1 = $binn->serialize($file);
// Filedata in binn list structure
$bin2 = $binn->serialize(['file' => $file]);
use Knik\Binn\Encoder\BinnEncoder;
use Symfony\Component\Serializer\Serializer;
$encoders = [new BinnEncoder()];
$serializer = new Serializer([], $encoders);
$serializer->serialize("\x40\xD0\x06", 'binn');