php MVC: The Future of CMS?
The MVC (Model, View, Controller) design pattern is not a new thing. It has been around since the 70s, and was first introduced commercially in 1980. It has now widely become the most effective and efficient way to code using many of the fantastic frameworks such as cakePHP, Codeigniter, Symfony and Ruby on Rails to name a few. Of course there are many more frameworks to choose from.
One thing that I have been thinking about recently is how the major CMSs structure their systems and the slow uptake of MVC frameworks.
Having used a lot of CMSs in my short career as a web developer it has become increasingly apparent that most of them have been built upon from previous older versions. This makes it very difficult to move the platform onto a new design pattern as dependencies on legacy code increase with every version.
I am not going to go into detail of every CMS out there as there are too many to count. I will be looking at the 3 major players as these are the systems I have had experience with:
Looking at the stats, we can see that only 2 in the top 5 use an MVC framework (Joomla! and, to an extent, ExpressionEngine).
vBulletin uses MVC, but is not a fully fledged CMS (although one is in development) and as such I will not be looking at this.
I will get Joomla! out the way first as I am fairly biased towards this CMS. I’ve developed in it for a long time due to it’s MVC nature and logical structure.
Joomla! has been a pioneer in this technology having built their own MVC framework to power their CMS. This framework can be used on it’s own or with the Joomla! CMS on top. The powerful framework is only really let down by the basic core functionality of the CMS. But because the MVC framework is there it is very very easy to expand and develop for.
A lot of developers talk of Joomla! as a beginner CMS, but in reality it caters for people with little to no coding experience, right up to the advanced developers looking to harness a fully fledged MVC framework. Which makes it really powerful.
It is a shame that it’s usage is slowly declining.
WordPress has exploded over the last decade to become the biggest CMS on the net in terms of usage. Due to it’s simple to use backend, extensive hooks system and its simple templating system. It has become one of the easiest to expand and develop for.
But while WordPress has been made really easy for developers to build for it’s not really built on top of any framework.
Would WordPress benefit from using an MVC framework?
In my opinion it would. I’d say it’s prime for such a framework. On a low level if you look at its structure it’s essentially a blogging platform which has been amended to become a CMS. The blogging structure is still there in, for example The Loop.
A very simple example would be that we could have different views for different categories of a blog and use different models to pull different information, without ever leaving the controller for the blog.
Will WordPress move to an MVC framework?
Without asking the developers I wouldn’t expect it. WordPress is the dominant power on the web because a wide range of users, from beginners to advanced developers and themers, can use it. I would highly doubt if the developers would risk alienating people looking to set up a quick and easy platform to start their own site/blog.
WordPress probably won’t move to a MVC framework but if they want to continue to grow, I reckon the developers need to at least look at the possibility of structuring their workflow better. Or even just making development more object orientated.
Drupal is without a doubt the powerhouse of the 4 CMSs. It is a CMS built for developers by developers. Which makes it all the more surprising that it has not followed the current trend of using MVC design patterns. It does however use the PAC (Presentation, Abstraction, Control) design pattern.
What’s the difference between MVC and PAC?
One of the main differences is that in PAC the presentation component does not deal with any of the data structuring – all that happens in the controller. In MVC the presentation (or view) requires some logic to know how to pull out the data from the model. This means some views can get very complex.
Drupal’s PAC uses the menu system as a controller, with abstraction coming from the nodes. The presentation is Drupal’s theme system. This is so integrated into the Drupal core that it makes it a very successful design pattern for Drupal.
Would Drupal benefit from moving to an MVC framework?
Yes and no. Drupal’s core has been developed as a PAC pattern instead of an MVC for a reason. MVC is a very good pattern to develop in, but current Drupal builds show there are others out there which are equally as good.
Drupal has announced that the newest version (Drupal 8) will use Symfony2 for some of it’s core components, bringing MVC to Drupal for the first time.
These are, of course, just my opinions. What do you think?