lukezbihlyj/vdf-parser

An open-source VDF parser for Valve's proprietary format used in Source games.

1.0 2015-02-13 13:18 UTC

This package is auto-updated.

Last update: 2024-04-05 22:59:06 UTC


README

An open-source VDF parser for Valve's proprietary format used in Source games. This package is 100% tested and available for use in any project under the MIT license. The parser currently supports all features of VDF, including:

  • Arbitrary whitespace, including tab characters and spaces.
  • Comments, which will be ignored during parsing.
  • Escaped strings, allowing backslash escaping inside strings for both keys and values.
  • Nested arrays, using recursion.

Installation

Via Composer

Add the following to your composer.json file and run composer update to update the dependencies and pull in the new package.

"require": {
    "lukezbihlyj/vdf-parser": "~1.0"
}

Usage

Parsing

$string = <<<VDF
{
    "key" "value"
}
VDF;

$parser = new VdfParser\Parser;
$result = $parser->parse($string);

//
// $result = [
//     'key' => 'value'
// ]
//

Testing

Unit tests are available and we strive to achieve 100% code coverage. Running the test suite is incredibly simple.

$ composer install
$ php vendor/bin/phpunit -c test/phpunit.xml

In addition to the phpunit results being output to the terminal, code coverage documentation will also be generated under the build/ directory.