• ALL
  • CATEGORIES

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.

Model View Controller design pattern

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:

  • WordPress
  • Drupal
  • Joomla!

 

The Top 10 CMS by number of website builds

Source: trends.builtwith.com/cms

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.

Joomla!

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

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

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?

Leave a reply

You can use these tags:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  1. Esteban says:

    Interesting analysis. In my own experience there are two main reasons why it’s difficult to develop CMS’s using MVC:

    First, the one you mentioned before: most popular CMS’s were developed a long time ago so it’s almost impossible to change its core, it would be better to write a new one from scratch.

    The other reason is that making the CMS in a way that Developers and even Web Designers can make things fast and easy goes, in some way, against the MVC pattern.

    For example in WordPress you can develop a website without touching a single line of code by only installing Widgets and Plugins and configure them all in the back-end. That goes against MVC principles where you are forced to write code in a clean way trying not to be repetitive by reusing as much code as possible (DRY).

    Even inside MVC community there’s a lot of discussion about how to implement it:

    Some people think you have to use the model only for getting information from the database and put all the logic in the controller.

    On the other hand some people says that is better to put all logic in the model and use the controllers only for passing data from the models to the view (Fat Models, Skinny Controllers).

    And now there’s the HMVC pattern that some Frameworks are adopting (like Kohana and Code Igniter).

  2. Johnny says:

    Maybe the title of this post should be changed to, php MVC: The Future of Blogging Platforms.

    • Hi Johnny,

      I would be interested to hear your thoughts on why Drupal and Joomla are classed as blogging platforms?

      Drupal especially is not an out the box blogging platform. It certainly now has the blog module and is handy using nodes and views to create a blogging platform, but that requires a small amount of set up to get to that point.

      Also Joomla CMS is geared more towards blogging (especially with Joomla 3) but at it’s core it is a development framework.

      WordPress is definitely a blogging platform first, CMS second.

      Hope to hear from you soon, I’m very interested to hear your thoughts.

      Thanks
      Kris

Sign up for the Manifesto newsletter and exclusive event invites