I downloaded a very simple MVC, and I am converting it to how I like it to be.
I see that in the index.php entry point file, a register object (class code below) is instantiated and a template and router object are passed to it that will be accessible globally in the MVC architecture.
What is the difference with just using a global array instead? Isn't that simpler? Or is there an even better way of handling this?
I'm just looking for what would be a better way of passing these objects.
I have read that magic methods are not good because it's hard to debug and re-factor. But I have read similar things about global arrays.
Class Registry {
private $vars = array();
public function __set($index, $value) {
$this->vars[$index] = $value;
}
public function __get($index) {
return $this->vars[$index];
}
}