title: PHP MVC Design issue
body: <p>I'm trying to build MVC pattern using OOP PHP. Please read the rest of the post to understand what I want exactly.</p>
  
  <p>This is the homepage controller which extends the main controller</p>
  
  <pre><code>class Home extends Controller {
  
      function __construct () {
          parent::__construct();
      }
  
      public function index () {
          $this-&gt;load-&gt;model("test");
          $this-&gt;test-&gt;get_all();
          $data = array (
              'name' =&gt; "Amr",
              'age' =&gt;24
          );
          $this-&gt;load-&gt;view("home_view",$data);
      }
  
  }
  </code></pre>
  
  <p>The Main Controller looks like this and extends loader class:</p>
  
  <pre><code>class Controller extends Loader {
      public $load;
  
      function __construct(){
          parent::__construct();
          $this-&gt;load = new Loader();
      }
  }
  </code></pre>
  
  <p>The Loader class which has the problem looks like this</p>
  
  <pre><code>class Loader {
  
      public $Error;
  
      function __construct(){
          $this-&gt;Error = new Error();
      }
  
      public function model($Modelname){
          $this-&gt;$Modelname = $Modelname;
          if (file_exists("models/".$Modelname.".php")){
              require_once $Modelname . ".php";
              $this-&gt;$Modelname = new $Modelname;
          }else{
              $this-&gt;Error-&gt;Not_found();
          }
      }
  
      public function view($Viewname,$data=NULL){
          if(is_array($data)){
              extract($data);
          }
          if (file_exists("views/".$Viewname.".php")){
              require_once $Viewname . ".php";
          }else{
              $this-&gt;Error-&gt;Not_found();
          }
      }
  
      public function helper($helper) {
          if (file_exists("helpers/".$helper.".php")){
              require_once $helper . ".php";
              $this-&gt;$helper = new $helper;
          }else{
              $this-&gt;Error-&gt;Not_found();
          }
      }
  
  }
  </code></pre>
  
  <p>What I need to do is to be able FROM HOMEPAGE Controller to do something like this:</p>
  
  <pre><code>$this-&gt;load-&gt;model("someModel"); // model name is test
  $this-&gt;someModel-&gt;someMethodInModel(); // the model method is get_all()
  // and the same for helper
  $this-&gt;load-&gt;helper("someHelper");
  $this-&gt;someHelper-&gt;someMethodInHelper();
  </code></pre>
  
  <p>Can anyone help me?</p>
  
  <p><strong>EDIT: The error that I'm getting when doing this is:</strong> </p>
  
  <blockquote>
    <p>Notice: Undefined property: Home::$test</p>
    
    <p>Fatal error: Call to a member function get_all() on a non-object</p>
  </blockquote>
  
  <p>NOTE: the model name is <code>test</code> and the model method is <code>get_all()</code></p>