定制 mintopia/vdfkeyvalue 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mintopia/vdfkeyvalue

最新稳定版本:v1.0.1

Composer 安装命令:

composer require mintopia/vdfkeyvalue

包简介

Encoder for Valve Software's KeyValue data format

README 文档

README

Total Downloads Reference Status

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.

Installation

VDFKeyValue is available on Packagist and installable via Composer.

$ composer require mintopia/vdfkeyvalue

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

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.

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.

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.

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

Author

Jessica Smith - jess@mintopia.net - http://mintopia.net

License

VDFKeyValue is licensed under the MIT License - see the LICENSE file for details

统计信息

  • 总下载量: 3.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-24