PHP解析器,用于解析TOML语言(https://github.com/toml-lang/toml)

v1.1.1 2019-07-10 21:19 UTC

This package is not auto-updated.

Last update: 2024-09-19 00:21:54 UTC


README

Packagist Packagist Build Status Packagist

PHP TOML解析器

PHP解析器,用于解析TOML语言(https://github.com/toml-lang/toml

支持

TOML版本:v0.4.0

要求

  • PHP 5.2+

安装

获取src/Toml.php并将其用于所需位置。

此库旨在保持简单,并支持PHP 5.2及以下版本。只要Toml.php文件在包含路径中,常见的自动加载器即可用于标准使用。

如果您需要在命名空间环境或特定自动加载器结构中使用它,您可以将其封装到自己的喜好中,创建一个简单的文件,例如

/some/project/namespace/path/My/Own/Toml.php
<?php
namespace My\Own

require("/path/to/github/cloned/repo/php-toml/src/Toml.php");
/some/project/autoloader/class/My/Own/Toml.php
<?php

require("/path/to/github/cloned/repo/php-toml/src/Toml.php");

class My_Own_Toml extends Toml {}

使用方法

<?php
require("../src/Toml.php");

// Parse TOML string
$tomlStr = file_get_contents('example.toml');
$result = Toml::parse($tomlStr);


// Parse TOML file path
$result = Toml::parseFile('example.toml');

测试

此项目支持toml-test测试套件

(https://github.com/BurntSushi/toml-test)

要运行测试套件,在您的环境中安装toml-test后,运行以下命令

toml-test /path/to/github/cloned/repo/php-toml/toml-test/test.php

贡献

  • 使用和测试库。
  • 在GitHub上报告问题/错误/评论/建议
  • 发送您的改进/新功能的pull请求给我

许可证

BSD许可证

Copyright (c) 2013 Leonel Quinteros.
All rights reserved.


 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
 met:

 * Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above
   copyright notice, this list of conditions and the following disclaimer
   in the documentation and/or other materials provided with the
   distribution.
 * Neither the name of the  nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.