I'm in the early stages on learning the Model, View, Controller framework with PHP. I'm getting the hang of it thanks to a tutorial found here. From my understanding, the controller will invoke the model so that the appropriate code can be ran in order for the viewable content to be rendered correctly.
The problem is that based upon that particular tutorial, it seems that I'm going to have to create an entirely new file for each page just to invoke the model in order to render the data viewable.
For example, in my controller.php file I have:
require_once("model.php");
class Controller
{
public $file;
public $league;
public function __construct($file, $league)
{
$this->file = $file;
$this->league = $league;
}
public function invoke()
{
// Everything that needs to be done in PHP will be done here so that once
// whatever file is included, it will just fit in fine and echo out perfectly
require_once($this->file.".php");
}
}
In my model.php file, I have:
class Model
{
private $file;
private $league;
public function __construct($file, $league)
{
$this->file = $file;
$this->league = $league;
}
More code. You get the idea...
}
In my teams.php file, I have:
$controller = new Controller("teams", "nba");
$controller->invoke();
But, since the teams.php has to invoke the the model and will ultimately require_once("teams.php"), I have to create an entirely new file just for the view. So, now the display will be featured on teams_display.php. Is there anyway that mod rewrite can help facilitate a framework whereby all of the pages happen in the index.php file while giving users the illusion that they're not?