dongliushui2001 2016-01-08 08:27
浏览 27
已采纳

如何将php配置文件传递给Node.js?

My php config file looks like:

define('hostname_con1', 'localhost');
define('database_con1', 'mydatabase');
define('username_con1', 'user');
define('password_con1', 'password');

What would be the "smart" method to use that in my nodejs application to avoid to define database parameters again in my nodejs application ?

var client = mysql.createConnection({
    host     : 'localhost',
    user     : 'user',
    password : 'password',
    database : 'mydatabase',
    charset: 'utf8', 
    insecureAuth: true,
});

I want to have 1 single config file for all (php and nodejs)

regards

  • 写回答

2条回答 默认 最新

  • dsfdsf8888 2016-01-08 08:31
    关注

    Store the configuration in a format that can be parsed by both languages and is not PHP specific, e.g. JSON, YAML, INI, whathaveyou.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部