PHP, MVC – continued

I’ve thought about this for a while after posting my previous attempt at using MVC to design a registration form.
So far, I’ve removed the need for the fields array, and simply used the Smarty “include” function to include html code for text boxes and checkboxes.
I also changed the controller so I could pass the names of different model and view classes to it. The controller should really create different view and model classes for each view IMO but that might be overkill for this. It’ll be a challenge when it comes to more non-linear apps where it’ll make sense to put code into seperate files.

Thank you Bruno for your comments. I think having as minimal a view class as possible is good and desirable considering the power of Smarty templates! The Template becomes the view class in other words.

Here’s a good description of the different components of the MVC architecture. There’s also a good page on Controller design.

By Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Twitter.

Leave a Reply