This topic is locked
[SOLVED]

 Creating a per install configuration setting

2/22/2014 12:27:00 PM
PHPRunner General questions
S
Stucco author

Is there a way create and read from a configuration file that can be set up per install, and not be replaced per install? There are various settings I would like to preserve per install across application deployments. One good example would be database connections settings. I currently have to build three times depending on where I am deploying to, but instead I would be able to build once and deploy the same build to three locations. I have other user settings that are more critical, but that is just an example.
I can use standard php file includes or read functions, but I was wondering if someone else had done this before in a better way.
Thanks!

Sergey Kornilov admin 2/24/2014

Using PHP includes is the best approach. Create a file named config.php and make changes to your app to read settings from this file.

W
wildwally 3/4/2014



Using PHP includes is the best approach. Create a file named config.php and make changes to your app to read settings from this file.


Following along the same lines of what Sergey mentioned I'll share with you what I do.
I have a php file called other-config.php in which I have all my common functions, settings, parameters that I use across the various sites I've built. I use to go into the source code of PHPR and add the include line to point to the other-config.php file, but found it got real old constantly having to update the source with any new PHPR update. Sergey was kind enough to offer me time saving tip and include the following code in the "After application initialized" event.
include(getabspath('other-config.php'));
Works like a charm, hope this helps you.

S
Stucco author 3/4/2014



Following along the same lines of what Sergey mentioned I'll share with you what I do.
I have a php file called other-config.php in which I have all my common functions, settings, parameters that I use across the various sites I've built. I use to go into the source code of PHPR and add the include line to point to the other-config.php file, but found it got real old constantly having to update the source with any new PHPR update. Sergey was kind enough to offer me time saving tip and include the following code in the "After application initialized" event.
include(getabspath('other-config.php'));
Works like a charm, hope this helps you.


Thanks for the tip! That will make this much easier.

S
Stucco author 3/16/2014

I ended up adding a variable to the database configuration settings in the Output area. This file already needs to be updated per install / deployment, so it makes sense to put it in there.