Skip to content
This repository has been archived by the owner on Mar 7, 2021. It is now read-only.

Create a Single initialization/bootstrap PHP file and Configuration Container #19

Closed
thepsion5 opened this issue Jun 10, 2016 · 1 comment

Comments

@thepsion5
Copy link

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:

  1. Setup autoloading (currently in includes/functions.php)
  2. autoload any global functions
  3. load all configuration from a separate file
  4. 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:

$database = DbConn::createFromConfig($configContainer);

This also forces you to think more about application architecture because you can't just access everything from everywhere.

@Firestorm-Graphics
Copy link

if you feel thats a way to go then fork and do a pull request with the amended files, i for one would be keen to see it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants