For many days, I've been re-designing my application, applying some custom pattern and making our code looks like a framework. I have something like this for separate the business logic, from views:

    if(file_exists($route . $urlpara[0] . ".template.php")){
        require_once($route . $urlpara[0] . ".functions.php");
        require_once($route . $urlpara[0] . ".template.php");
        // 404 error

$route means the route.

$urlpara[0] means a parsed URL, where $urlpara[0] should be in this case the URL. In this case, we could say $urlpara[0] = index. So this would like like this without variables:

        // 404 error

Inside index.template goes the view, and inside index.functions goes the model.

Here's the .htaccess

RewriteEngine On
Options -MultiViews
Options +FollowSymlinks

RewriteBase /script/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Basic params MVC
RewriteRule ^(.*)$ index.php?page=$1 [L]

Here the index.php (the part where it reads and splits up the model/view):

    $exploded = explode('/', $_GET['page']); // pagename/param1/param2/etc..

    $route = 'script/path/';
    $first_param = $exploded[0];
    $second_param = $exploded[1];
    // Controller
            if(file_exists($route . $first_param . ".template.php")){
                require_once($route . $first_param . ".functions.php");
                require_once($route . $urlpara[0] . ".template.php");
                // 404 error

    // now it checks if param1 = pagename exists. For example dashboard.template.php. Same with dashboard.functions.php

function generateTitle(){
echo 'this title generated dynamically';

Within dashboard.template.php we find this:

<!-- View -->
<title><?php echo generateTitle(); ?></title>
foreach($whatever as $some){
echo $some;

And within the dashboard.functions.php we find this:

// Model
$whatever = array('test', 'test2', 'test3');

I don't really know if I'm doing it well. Could be this represented as a MVC pattern?

  • 3
    \$\begingroup\$ Hard to say: there's not enough code to see if there's a clear separation of responsibilities. There seems to be little or no communication going back and forth between an alleged controller (which also does the routing and dispatching it would seem), and the model layers. I've answered MVC questions in detail here and here maybe that helps to get you started \$\endgroup\$ Jun 25, 2014 at 16:37

2 Answers 2


what you have posted is orthogonal to MVC. MVC deals with user interfaces. It has later been reshaped many times to fit various platforms such as the web but the original ideas came out of Xerox some forty years ago and tryed to bridge the gap between the user and the model in the computer (the M) though it's known as MVC it actually MVC-U where the U is for user and the U is there to stress the relationship between the system (MVC) and the User (U).

There's no interface in the code you've posted and hence at best it can be viewed as a mechnism to start some (sub)system that's build on MVC. The Model is suppossed to represent piece of the users mental model. How they see the world and it has been shown that if there's a 1:1 relation ship between the real life model and the one in the system Users are better at using the system. The view is what the user sees. You can say it's a visual representation of the model and the controller is coordinating user inputs and model updates (which in turn are reflected by an update of the view)

So the short answer would be "no" but the longer is more down the line of "MVC is something unrelated to the problem you are solving with the above code"

  • \$\begingroup\$ note: interface is not 100% needed for MVC to be built. It is recommended though if you are following SOLID design patterns. But MVC just need enough Model-View-Controller to be interconnected for it to be achieved. \$\endgroup\$
    – azngunit81
    Jun 25, 2014 at 18:05
  • \$\begingroup\$ @azngunit81 your assumption is incorrect at least when compared to the original version of MVC. Uncle Bob and SOLID came a long time later than MVC, he did not define it, that credit goes to Trygve Reenskaug Take a look at Trygve Reenskaugs own writings on the pattern dating back to the end of the seventies. heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html. And the pattern is formally called MVC-U for Model-View-Controller-User to emphasis the user and not only the system. \$\endgroup\$
    – Rune FS
    Jun 25, 2014 at 18:50
  • \$\begingroup\$ Hello guys. I've just edited the question, now it's more clearly. \$\endgroup\$ Jun 26, 2014 at 15:36

Going with @Rune FS's comment and also the fact that @Elias Van Ootegem has explained MVC/Solid in extensive review posts (and so did I):

  1. Your code is not sufficient and obscured to even have a proper logic/framework for us to even help on this scale.

  2. Why are you rewriting existing MVC frameworks (Yii, Laravel, Silex, Symfony2...etc) just because your business logic needs to be updated? It should be "take an existing optimal framework, then take your req doc, and build on that". You would be surprise by the fact that a lot of today's composer style framework can be very modular (like Laravel) and you can just selectively work with specific components (such as taking ONLY the eloquent model, if you need the ORM)

  3. From what you have provided us, we can't determine the basis of MVC (model - view - controller), therefore just like @Rune FS suggested, we can't conclude any relationship. This looks more like REQUIRE/CHECK and including templates rather than a framework MVC.

Bottom line: unless you provide sufficient breakdown of what the other files are, and a proper MVC breakdown, what you have presented us is not MVC.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.