This is an old post I stumble onto and the solution I gave is this:
I created a JSON file (my code makes extensive use of these which I call tokens) to become the single source of truth and to be open at the same time for modifications from who knows what new things will emerge in a application/framework:
// accounttoken.json
{
"site": {
"email": "[email protected]",
"password": "Bty1!",
"firstname": "John",
"secondname": "Doe",
"country": "USA",
"username": "Admin",
"role": "admin",
"protocol": "http://",
"domain": "a9623c7ca853.eu.ngrok.io",
"site_key": "fgRt4%$x!0($DqJi",
"language": "en"
},
"google": {
"client_id": "51965.apps.googleusercontent.com",
"client_secret": "8Kz"
},
"db_mysql": {
"db_port": 3306,
"db_user": "<user>"
},
// more entries here...
}
Now, all you have to do is to consult your entries in one file:
// find php executable
cent$ whereis php
php: /usr/bin/php7.0 /usr/bin/php /usr/lib/php /etc/php /usr/include/php ...
// start interactive shell
cent$ /usr/bin/php7.0 -a
php > $json = file_get_contents('accounttoken.json');
php > $json = json_decode($json, true);
php > echo('Your domain is: ' . $json['site']['domain']);
php > echo('The site url is: ' . $json['site']['protocol'] . $json['site']['domain']);
php > quit