什么是配置文件的最佳文件格式 [英] What's Is the Best File Format for Configuration Files

查看:599
本文介绍了什么是配置文件的最佳文件格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PHP中创建一个框架,需要有一些配置文件。



这些配置文件的最佳格式是什么?



这里是我最好的量化:


  1. 通过PHP轻松解析。如果我不必写任何解析代码,这将是很好的,但这不是一个破解。

  2. 即使有大量的条目仍然容易阅读人


  3. 是一种广泛使用的标准,没有自定义格式。

  4. $ b

    我开始使用XML,但很快就放弃了明显的原因。我想到了JSON和YAML,但想看看还有什么。

    解决方案

    INI文件格式怎么样?这是一个事实上的配置文件标准,PHP有一个内置的解析器格式:



    parse_ini_file


    I am creating a framework in PHP and need to have a few configuration files. Some of these files will unavoidably have a large number of entries.

    What format would be the best for these config files?

    Here is my quantification of best:

    1. Easily parsed by PHP. It would be nice if I didn't have to write any parsing code but this is not a deal breaker.
    2. Remains easily read by humans even when there are a large amount of entries
    3. Is a widely used standard, no custom formats
    4. Succinctness is appreciated

    I started out using XML, but quickly gave up for obvious reasons. I've thought of JSON and YAML but wanted to see what else is out there.

    解决方案

    How about an INI file format? It's a de facto configuration file standard, and PHP has a built-in parser for that format:

    parse_ini_file

    这篇关于什么是配置文件的最佳文件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆