Here is my php config file I use (config.php)
<?php
class DbConfig{
const NAME = 'myDB';
const USER = 'myUser';
const PASS = 'myPass';
const HOST = 'localhost';
}
class Servers {
const NODE = 'http://127.0.0.1';
const RTMP = 'http://127.0.0.1:1935/';
}
?>
I would like to use this DBConfig inside my nodejs (I use npm mysql package).
What is the best way/strategy to have 1 single config file for both PHP and NODEJS ?
Regards
According to the 12 factor app use environment variables. Sensitive credentials should not be checked into your version control repo.
If you cannot use environment variables, I would advise using something like a file outside of version control like /config/database.json
You can easily parse .json in Node as defined here or PHP defined here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.