A tagged netstring codec for PHP
PHP
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/Phuedx/TNetstring
test
.gitignore
.travis.yml
LICENSE
README.markdown
composer.json
composer.lock
phpunit.xml
tnetstring.php

README.markdown

TNetstring Build Status

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.