One of the latest trends in website development is that of the Model-View-Controller (or MVC) design ideology. For those individuals reading who are unfamiliar with MVC, allow me to give you the rough sketch of what it is. The idea comes from the concept of three distinct tasks of an Application:
- Read or Write Information from a data source.
- Process that information in some way.
- Display the processed information.
Those three tasks are at the heart of nearly every application on the market. We’re all a bunch of data manipulators! Just when you thought that your checking account had some greater significance, right? These three tasks make up the three parts of MVC. The Model is a representation and a means of communicating with your data source. The Controller is what processes your information for you. And finally, the View is what displays your information in a friendly format.
I first had the pleasure of being exposed to this via my position with the University of Georgia’s EITS. However, if you want a shining example of an artfully designed MVC Framework, the best example I’ve seen is Ruby on Rails. While Rails may singlehandedly be responsible for giving Ruby a jump into the spotlight of web development, it is not without its problems. Rails is, for example, very resource heavy if not implemented exactly right.
So, in light of my love for the ease of developing for Rails and my frustration with the fact that finding a web host who adequately supports it I have started work on developing an MVC framework that brings some of the things I love about Rails into the PHP arena.Some of the biggest stifles with PHP come from PHP’s biggest strengths – flexibility. PHP can be tasked to do a number of different things. However, for web application development – the tasks are fairly similar. Hence the creation of PHP Application Frameworks. The organization I work with at the University of Georgia uses their own home-brewed MVC. I could not dream of replicating all of the useful things that their framework does. However, my contract projects wouldn’t need things like LDAP authentication against the University of Georgia servers.
So, I’ve set out developing my own Framework, targeted specifically at small web applications. I have titled this framework the ‘W’ Model-View-Controller, or “WMVC” for short.
Currently, development on the View and the Controller side is functionally complete. The hard part will be the Model. But here is what I’ve accomplished so far above what I’ve seen in other PHP-based MVC’s that I tried:
- Smarty integration.
- Elimination of smarty assign blocks. Public instance variables in the Controller’s class are translated over to Smarty automatically. No more assign blocks. No more name differences between the variable name in the Controller and the variable name in the Smarty. Less time consumed by tracking down differences.
- Minimalist database drivers. Database drivers implement only the very basic functionality, and the driver can be changed out by changing a value in the config file.
- Speaking of config files, there’s only two so far — application.ini and a .htaccess file. Those are the only two files an application developer would have to touch to get a WMVC application running. (I might be forced to add a third, but I’m hoping not.)
- Separation of Framework code and User code. The WMVC assumes nothing about the task of the application you’re developing. All it knows is that you’ll be accessing some data, doing something with the user input and that data, and displaying something. Authentication and such is left up to the user to implement.
Additionally, I intend to accomplish the following before I roll out my first production WMVC app:
- A Model class that knows about the table it represents auto-magically. Knows which fields are strings, which one is the primary key, and which are required. And tells you before you try to throw bad data at the database. Auto-magically.
- Some sort of installation and upgrade framing. Since installing your application and your actual application are really two distinct beasts, I thought separating their behavior a little bit might be wise, so I’m working on a easy to use method of rolling out upgrades to your application’s database (inspired by Rails migrations). Writing your upgrade code should take a fraction of the time of writing your application code.
- Last but not least, automatic upgrading of the WMVC Framework. The hardest part about maintaining any computer systems is keeping everything up-to-date. I fully expect to be required to roll out bugfixes and security patches to WMVC after production sites are live. So, to save the legwork, I want WMVC to be self-updating. The Framework should, and hopefully will, be able to update itself without breaking any website it’s running.
I strongly believe the points I outlined above will make for a superior web framework. I still have not decided whether or not I will open source this. Some interest in using a MVC like this one has already been expressed. So, if you’re interested then let me know by leaving a comment (you can log in with either a username/password on this blog or with an open id). Also, if you have any thoughts on what I’ve written, I’d love to hear them.
May your voice be heard!