phuedx/tnetstring

A tagged netstring encoder/decoder for PHP.

Installs: 599

Dependents: 4

Stars: 5

Watchers: 1

Forks: 1

Language: PHP

v2.0.0 2014-12-10 19:55 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 has 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-2014 Sam Smith. See the LICENSE file for full copyright and license information.