You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 7, 2021. It is now read-only.
Currently, there's lots of configuration info and setup code scattered through different files. There should really only be a single place where configuration and application setup takes place, and it would be a good idea to move your config and setup there. Ideally, your bootstrap file should:
Setup autoloading (currently in includes/functions.php)
autoload any global functions
load all configuration from a separate file
Instantiate any global objects necessary (an application kernel or configuration container, for example)
Then all of your public PHP files only need to include the boostrap file. Instead of including various config files in your class constructors, you can use the configuration container to pull out the specific configuration they need. For example, your DbConn class might look like this:
Currently, there's lots of configuration info and setup code scattered through different files. There should really only be a single place where configuration and application setup takes place, and it would be a good idea to move your config and setup there. Ideally, your bootstrap file should:
includes/functions.php
)Then all of your public PHP files only need to include the boostrap file. Instead of including various config files in your class constructors, you can use the configuration container to pull out the specific configuration they need. For example, your DbConn class might look like this:
$database = DbConn::createFromConfig($configContainer);
This also forces you to think more about application architecture because you can't just access everything from everywhere.
The text was updated successfully, but these errors were encountered: