PHP 和 Perl 共享的好的纯文本配置文件格式是什么?
这更多的是一个概念问题,而不是一个需要解决的编码问题。 我们有许多 PHP 和 Perl 脚本。
公司各处分布着大量 MySQL 服务器,每个服务器都有大量不同的用户/权限组合。
我想创建一个中央配置文件,可能是纯文本文件,其中包含所有连接数据的列表。每种语言都需要能够读取文件并将其解析为可用的格式。
我想知道实现此目的的任何首选方法。
This is more of a concept question rather than a coding problem to be solved.
We have a number of scripts in both PHP and Perl.
There are a large number of MySQL servers spread around the company each with a large subset of different user/permission combos.
I would like to create a central configuration file, maybe as plain text file, that has a list of all the connection data. Each language would need to be able to read the files and parse them into a usable format.
I would like to know any preferred method of implementing this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
选择
ini
、xml
、yaml
或json
。 Perl 和 PHP 中有一些库可以处理这些格式。Pick any of
ini
,xml
,yaml
orjson
. There are libraries for working with any of these formats in Perl and PHP.对于 PHP,您有 parse_ini_file,对于 Perl,您有 Config::INI::Reader。这两者都应该可以很好地满足您的需要,并允许人类轻松编辑的结构化配置。
For PHP you have parse_ini_file and for Perl you have Config::INI::Reader. Both of these should do you pretty fine and allow structured configuration that's easily editable by humans.