phuedx/tnetstring

A tagged netstring encoder/decoder for PHP.

v2.0.1 2016-03-21 19:39 UTC

This package is not auto-updated.

Last update: 2024-11-20 11:25:36 UTC


README

A tagged netstring codec for PHP.

Installation

The recommended way to install TNetstring is with Composer.

composer.phar require phuedx/tnetstring

Usage

<?php

require_once __DIR__.'/vendor/autoload.php';

$payload = array(
    'authors' => array(
        array(
            'name'     => 'Sam Smith',
            'email'    => 'yo@samsmith.io',
            'homepage' => 'https://github.com/phuedx',
        ),
    ),
);

$codec = new \Phuedx\TNetstring\Codec();
$encoded = $codec->encode($payload);
$decoded = $codec->decode($encoded);

There's also a JSON-like API:

$encoded = tnetstring_encode($payload);
$decoded = tnetstring_decode($encoded);

Resources

tnetstrings.org had all of the information you'll need to get acquainted with tagged netstrings.

License

TNetstring is licensed under the MIT license and is copyright (c) 2011-2016 Sam Smith. See LICENSE for full copyright and license information.