title: The best option for calling model functionality in a PHP controller
body: <p>I am building a custom MVC framework using PHP. My problem is when I want to access any model class through the controller class. One way I have seen this done is through a registry design pattern using magic methods such as get and set, though PHP get and set are considered bad practise by some. I have read about dependency injection done through a container, but I can not see this working effectily as the container would have to call the models or it would have to contain the models which would defeat the purpose of MVC and create a massive super class. Singleton is seen as bad practise. Is there any solutions or improvements of the methods I have mentioned. It may just be my understand and knowledge of PHP needs improving. </p>
  
  <p>Currently I have this: router.php (loads up controllor through a GET varible</p>
  
  <pre><code> &lt;?php
  
  class router {
  
  
  
  function __construct() {
  
      if (file_exists("controller/".$_GET['url']."Controller.php"))  {
  
  
         function __autoload($controller) {
  
             $controlinclude = "controller/".$controller.".php";
              include $controlinclude;
  
        }
         $control = $_GET['url']."Controller";
          new $control();
  
  
      }
      else    {
  
          // throw exception
      }
  
  }
  
  }
  ?&gt;
  </code></pre>
  
  <p>Hope that makes sence</p>