PHP MVC with Tom Butler

In the PHP chat a link got passed around (see “Deploying MVC on the web” below) and I thought it’s worth to link the multiple MVC related articles by Tom Butler. He is one of those persons who actually leave references after their articles, that’s fine.

What’s fine as well is that he is not shy to offer his own sight on things regardless of the way so far of usage of MVC and realated terminologies that have squashed our minds too far. Probably just the right time for a re-read.

Model-View-Confusion Part 1: Why the model is accessed by the view in MVC

(by Tom Butler; 6 Jul 2010) MVC is a common subject in the PHP community at the moment. There are a large body of articles, tutorials and code examples on the subject. Most of which deviate from the traditional approach to MVC and subscribe to an approach closer to MVP. Very few of these follow the MVC standard of allowing the view access to the model. Yet this is what they ascribe to be. This article explains why the view should have access to the model and the problems which are created by taking the differing approach commonly used throughout the PHP community. The full article

Model-View-Confusion Part 2: Maximising View reusability with View Helpers

(by Tom Butler; 9 Jul 2010) Part 1 discusses MVC and explains why the view has access to the model in MVC. Taking this approach, however, is not as simple as it seems. Giving the view access to the model creates a whole new set of problems. The difference is, these problems are easily fixed. This article presents a useful way of fixing the problems while retaining high reusability and flexibility. The full article

MVC In PHP Part 1: Hello World

(by Tom Butler; 8 Sep 2010) Since writing my article Model-View-Confusion part 1: Why the model is accessed by the view in MVC I have received several e-mails asking me to provide a simple example of MVC in PHP. So I’ve decided to create one. However, my intent is to build up from a very simplistic example and include some of the reasoning behind certain design decisions and considerations involved in deploying MVC on the web.

As stated in my previous article, a lot of other tutorials/articles go off into irrelevant sub-topics. I want to cover pure MVC. As such, you’ll find no discussion of template engines, directory structures, DAO, ORMs or similar in this article. This is pure MVC. From the ground up I’ll explain the original implementation of MVC and why it has to be adapted to work on the web. The full article

MVC In PHP Part 2: Deploying MVC on the web

(by Tom Butler; 20 Sep 2010) In part 1 I provided a basic example of implementing a standard MVC set up in PHP. The biggest problem with this standard approach on the web is scalability. In the examples, I have explicitly stated which model, view and controller are initiated. Which is fine in the desktop application environment where it was conceived. On the web, however, there are some constraints imposed by the underlying architecture.
A reasonable request would be to substitute the model being used. How can we do this on the web? Have a specific PHP file for each triad, initialising all 3 components? It’s certainly an option, but ties you down to a URI structure and specific PHP files for each task. Then there’s the repeated code.

For example, what about the very common scenario of putting the MVC triad inside an overall site layout? It would require even more repeated layout generation code in each page. What if this layout code has to be updated? That’s a lot of places to change it! Obviously this isn’t viable in any non-trivial project.

How, then, can the script know which model view and controller are needed? The full article

MVVM, MVC it’s all just roman numerals to me

(by Tom Butler; 5 Nov 2010) An exploration of the differences between MVC and MVVM and their relative efficacy for use on the web. In PHP specifically, a definition of MVC has evolved that does not conform to the standard definition of MVC anyway. But is MVC really the best thing to strive for anyway? The full article


Read On: Architecture the Lost Years (Robert Cecil Martin; 4 Nov 2011)

This entry was posted in Linked, PHP Development, Pressed, The Know Your Language Department and tagged , , , , . Bookmark the permalink.

One Response to PHP MVC with Tom Butler

  1. Tom B says:

    Hey,
    I’m the author of these articles. I saw this link popping up in my analytics. Thanks for linking to them! I’ve actually been intending to add more for quite some time. My next step was going to be showing how a basic database driven blog would work using the concepts I’ve already described. I think you’ve spurred me on to getting around to writing it down!🙂

    If you, or anyone reading, has any questions or comments about the articles above feel free to contact me!

    Tom

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s