I'm working on a project and here's what my coding practice looks like.
- I load all the class files in config
- I create an instance of the VITAL classes in the configuration (ie.
$database = new Database()
). The non-vital classes get created within the pages. - Inside the pages I just use
$database->query
to fetch data. - Inside functions I call
global $database
and take it from there.
Is this practice normal? Discouraged? Encouraged? Which method of code structure do you implement when you work on a large project?