PHP MVC: How to implement an effective Controller/View Association like ZendFramework guys do!

Posted by Navi on Stack Overflow See other posts from Stack Overflow or by Navi
Published on 2010-05-28T15:45:54Z Indexed on 2010/05/28 15:52 UTC
Read the original article Hit count: 263

Filed under:
|
|
|

Hi, I am making my own PHP-MVC framework. i have a question regarding Controller and View Association. I love the way Zend framework uses view within Controller as follow:

$this->view->data = 'Data here';

so it can be used in view as follow:

echo $this->data;

I am wondering how can i implement this association. I want to remove codes between /** **/ and want to replace with some magic functions. My codes for controller as as follow:

 class UserController extends Controller{
  /************************************/
  public function __construct(){
   $this->view = new View();
   $this->view->setLayout( 'home' );
  }
  function __destruct(){
   $this->view->render();
  }
  /************************************/
  public function index(){
   $this->redirect('user/login');
  }
  public function login(){   
  }
  public function register(){
  }
  public function forgotPassword(){
  }
 }

Thanks and best regards, -Navi

© Stack Overflow or respective owner

Related posts about php

Related posts about mvc