I creating PHP applications and I have question about architecture.
I have some systems in my app.
For example, Cache system, Output system, Applications system, etc.
Also I have Registry for link this systems together.
Here is example of using Cache in Applications:
class Manager {
public function __construct() {
$registry = \Jx\System\JxRegistry::getInstance();
$this->JxCache = $registry -> JxCache;
}
public function getAppInfo($JxId) {
$someInfo = $this->JxCache->Applications->$JxId;
}
}
But this way I need to call Registry everywhere and I need to create local variables to store objects.
I have another idea, something like this:
class Kernel {
public function __construct() {
$this->JxCache = new JxCache;
}
}
/* .. */
new Kernel();
/* .. */
class Manager extends Kernel {
public function __construct() {
}
public function getAppInfo($JxId) {
$someInfo = $this->JxCache->Applications->$JxId; //JxCache declared in class 'Kernel'
}
}
Which variant more right?
Can you suggest your variants?
Thank
Yii framework has a different approach may be you can like it:
Yii behaviors