PHP decoder and encoder for the Erlang Term Format.
Install this library through composer using
composer require obsidian/etf
Minimal decoding example:
use Obsidian\ETF\Decoder;
// the binary erlang term format string (#PID<0.81.0>)
$binary = base64_decode("g2d3DW5vbm9kZUBub2hvc3QAAABRAAAAAAA=");
$etf = new Decoder();
$pid = $etf->decode($binary);
var_dump($pid);
/*
class Obsidian\ETF\PID#6 (4) {
public $node =>
class Obsidian\ETF\Atom#5 (1) {
public $atom =>
string(13) "nonode@nohost"
}
public $id =>
int(81)
public $serial =>
int(0)
public $creation =>
int(0)
}
*/
Minimal encoding example:
use Obsidian\ETF\Atom;
use Obsidian\ETF\Encoder;
$value = new Atom('hello');
$etf = new Encoder();
$binary = $etf->encode($value);
var_dump($binary);
/*
string(8) "w║hello"
*/