PHP code example of mintopia / vdfkeyvalue

1. Go to this page and download the library: Download mintopia/vdfkeyvalue library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mintopia / vdfkeyvalue example snippets




use Mintopia\VDFKeyValue\Encoder;

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



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);
bash
$ 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"
        }
}