I am trying to learn webdesign using the MVC design pattern. Right now, I am stuck at a point where my code gets more complex, and I am unsure about the structure and where to put which code parts.
I started with an index.php file as my controller, which right now does not much more than loading the Slim framework to render the different views
$app->get('/', function() use ($app){
$app->render('header.php');
$app->render('content.php');
$app->render('footer.php');
});
$app->run();
Then I built a complex content.php where I do a lot of form data logic, reading from a server directory, and echoing the results mixed with html tags. That surely will violate the MVC pattern, right?
What is the general approach to this? Should I put all the logic inside the index.php, store the results in an array, and pass that to the framework's render function, like this:
$app->get('/', function() use ($app){
//Do something and store results in an Array
$app->render('header.php', anArray());
$app->render('content.php', anArray());
$app->render('footer.php', anArray());
});
$app->run();
How can I prevent index.php becoming too complex when doing so? Is there a different approach to take?