为什么要使用dotenv库而不是解析ini文件? [英] Why use dotenv library instead of parsing ini file?
问题描述
在PHP中,可以使用parse_ini_file()
读取* .ini文件.但是,各种框架(包括Laravel)选择引入一个单独的库来解析环境文件.
Within PHP, *.ini files can be read by using parse_ini_file()
. However, various frameworks (Laravel included) opt to, instead, bring in a separate library to parse an environment file.
使用此"dotenv"解决方案代替ini文件和内置PHP函数的背后原因是什么?
What is the reasoning behind using this "dotenv" solution instead of ini files and the built-in PHP function?
推荐答案
这是一个很好的问题.我在 php.net 上找到了一些提及(搜索通过关键字parse_ini_file
).我想主要的问题是parse_ini_file
不支持某些功能,例如常量,表达式等.此外,我想有些开发人员希望以OOP风格执行此类操作.
It's a good question. I've found a few mentions on php.net (search by the keyword parse_ini_file
). The main problem, I suppose, is that parse_ini_file
doesn't support some features, such as constants, expressions, etc. Also, I guess, some developers would like to perform such operations in OOP style.
这篇关于为什么要使用dotenv库而不是解析ini文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!