I am not sure if this belongs under PHP Code or perhaps Theorycrafting?
Here is the situation.
There is a core set of classes which are usually included with most projects that are being worked on, primarily configuration and settings based classes and a couple of XML and socket type classes.
The problem is keeping all these classes up to date across every project. Occasionally there is a better way or an improvement to one of these core files. I don't mind having to update each projects use of the class, but what I don't want to do is copy the newly updated class files into the directories of every project that uses them.
My IDE is NetBeans and I have recently set up an Include Path for each project as a reference to a centralised location of the core classes. Here in lies the first problem:
This isn't as huge a problem as the next mind bending problem.If all these files are only included via an IDE include path, then is there an easy way to also make sure the files are uploaded (in the correct LOCALISED PATH) inside the project under say a /packages/<name>/ directory and how do you manage the inclusions?
In order to help streamline my application configurations, there "used" to be a core config class which contained settings such as database details or debug settings. This class is a STATIC class making it accessible to any class at any given time.
In order to allow for "per project" settings, I decided that this class had to be extensible so that each project could store its own unique settings... All good and well at this point, now for the tricky part...
The core class files make reference to some of the "static" functions in the config class such as myconfig::debugMode() to determine if the application is currently running in debug mode.
Scenario:So if these classes make reference to static methods inside a static class, then how do you reference a constructed child object of myconfig without being aware of the name of the class when inside these other files?
I create a new project, and extend the myconfig class and call it myprojectConfig while setting database values, debug modes etc.
I can now automatically create my database connection within my classes by defining:
Code: Select all
class account extends VNDatabase {
public function __construct(){
$_conf = new Settings();
$_conf->dbsettings = myprojectConfig::getdbconf();
parent::__construct($_conf)
}
}Otherwise my thought is that as a part of the ::getdbconf() function, or during the construction of the Settings object I could store the class name and simply reference it like:Short of actually telling VNDatabase of the change in config class, is there any way for it to figure out where the configs could be coming from?
Code: Select all
$_conf->configclass = "myprojectConfig";
//VNDatabase
$this->configclass = $_conf->get('configclass');
$this->configclass::debugMode();