2017 © Pedro Peláez
 

library vdfkeyvalue

Encoder for Valve Software's KeyValue data format

image

mintopia/vdfkeyvalue

Encoder for Valve Software's KeyValue data format

  • Friday, May 5, 2017
  • by mintopia
  • Repository
  • 1 Watchers
  • 2 Stars
  • 289 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 33 % Grown

The README.md

VDFKeyValue - Valve KeyValue Format Encoder

Total Downloads Reference Status, (*1)

This library encodes native PHP data in to Valve Software's VDF KeyValue format. This is used by the Source engine and many SourceMod mods., (*2)

Installation

VDFKeyValue is available on Packagist and installable via Composer., (*3)

$ composer require mintopia/vdfkeyvalue

If you do not use composer, you can grab the code from GitHub and use any PSR-4 compatible autoloader., (*4)

Basic Usage

<?php

use Mintopia\VDFKeyValue\Encoder;

// Create a new instance of the encoder and use it
$encoder = new Encoder;
$encoder->encode('foobar', $myObject);

You can encode objects, arrays, string, integers and anything else that can be represented by a string., (*5)

The KeyValue format doesn't strictly support anything more than nested keys and values, so any objects or numerical arrays ended up being treated as associative arrays before encoding., (*6)

Example

<?php

use Mintopia\VDFKeyValue\Encoder;

$maps = new \stdClass;
$maps->payload = 'pl_goldrush';
$maps->cp = 'cp_badlands';

$data = new \stdClass;
$data->game = 'Team Fortress 2';
$data->appid = 440;
$data->bestmaps = $maps;
$data->characters = [
  'Demoman',
  'Scout',
  'Heavy Weapons Guy'
];

$encoder = new Encoder;
echo $encoder->encode('gameinfo', $data);
$ php example.php
"gameinfo"
{
        "game"  "Team Fortress 2"
        "appid" "440"
        "bestmaps"
        {
                "payload"       "pl_goldrush"
                "cp"    "cp_badlands"
        }
        "characters"
        {
                "0"     "Demoman"
                "1"     "Scout"
                "2"     "Heavy Weapons Guy"
        }
}

About

VDF KeyValue Format

The format is a simple nested tree structure, similar to JSON but without arrays and requiring a root key., (*7)

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub, (*8)

Author

Jessica Smith - jess@mintopia.net - http://mintopia.net, (*9)

License

VDFKeyValue is licensed under the MIT License - see the LICENSE file for details, (*10)

The Versions

05/05 2017

dev-master

9999999-dev

Encoder for Valve Software's KeyValue data format

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Jessica Smith

05/05 2017

v1.0.1

1.0.1.0

Encoder for Valve Software's KeyValue data format

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Jessica Smith

24/05 2016

1.0.0

1.0.0.0

Encoder for Valve Software's KeyValue data format

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Jessica Smith