I am writing my first basic MVC template templates in PHP. I know that global variables are bad, and I also know that I don't want all my classes to have access to all my configuration vars.
I have a settings.php file that I would like to define in a group of constants, for example, information about db connection, information about directory structure, email addresses, etc. This will be one central location where all my important information is stored.
What is the best way to implement a configuration class so that each of my base classes for my controller and model has access only to the necessary configuration files? For example, my base model class should have access to db connection information.
Basically, I’m just asking how does everyone ride their own MVC settings, process configuration information without declaring global variables, for example, we returned on procedural days.
Thank.
source
share