I would like to know how does
$this->view->foo from controller becomes $this->foo in view file i.e. in .phtml file
I would like to know how zend framework handled this.
It's all handled by magic methods __get
and __set
in Zend/View/Abstract.php
.
In short: do not do that in your own project, just use a similar process to ZF2/3 where parameters are passed into the constructor :)