views:

616

answers:

10

View is easy to be separated from MC,

but how to separate M and C?The difference seems a little vague to me.

I'm using PHP.

+1  A: 

Maybe this is useful for you: http://www.phpmvc.net

Konamiman
+8  A: 

I would not start developing an MVC framework until the point when I knew what MVC was, very crisply and clearly, and was able to explain the difference between the model and the controller with my eyes closed. The way to do it is to learn from existing frameworks (Cake, Zend, QCubed, etc).

Alex
Agreed. And I say that, having myself created two complete MVC systems without having the slightest clue what a MVC system was supposed to look like, with very patchy and annoying results. My third one was pretty good tho :D *(Still, nothing next to Cake or Zend)*
Atli
I agree also, however, there's really no better way of learning how a wheel works, than reinventing said wheel. I.e. it's a good idea to roll your own (for understanding and learning), albeit using it is not.
nikc
It's not really that much harder to describe something with your eyes closed than it is with your eyes open...
Charlie Somerville
+2  A: 

Here is the step-by-step guide to developing a MVC framework using PHP:

http://phpro.org/tutorials/Model-View-Controller-MVC.html

Really easy, good tutorial.

Sarfraz
+4  A: 

Step 1: spend time contributing to an existing open source MVC framework.

Step 2: start contemplating making your own.

Step 3: stop panicking.

Robert Grant
+5  A: 

The "model" part of MVC refers to the data access layer, so you should create classes to read from/write to the database. Often it's one model per database "entity", so, say, one class for articles, one class for categories, plus a simple database class is a good idea.

The "controller" part is the general logic, and usually the entry point. Here you check the input and requested page, use the model to find the correct data and store in variables for the view.

The "view" part as you said is quite easy. Just include a file from the controller that mostly consists of HTML but outputs your PHP variables.

DisgruntledGoat
A: 

Start with the basics:

Understanding MVC Architecture from its Origin (part I) http://learnnewprogramming.com/blog/understanding-mvc-architecture/

Rebol Tutorial
A: 

To read basics on How MVC returns data to browser go to http://w3mentor.com/learn/php/php-language-basics/how-mvc-returns-data-to-browser/

A: 

M (Model) = Business Logic

C (Controller) = Application Logic

presario
A: 

This could be a good starting point: MVC in PHP is a tutorial covering the basics of MVC.

php html
+1  A: 

There's a lot to be said about letting the infinite army of monkeys (like all of us) maintain code that really grabs their attention, and then leveraging that in your own work instead of completely re-inventing the wheel. If you DO decide to create your own MVC framework, I'd encourage you to integrate specialist projects (e.g. an ORM-layer, or templating engine, etc.) that are being developed by people who TRULY LOVE those projects because the result will probably be stronger pieces within your whole, which will ultimately make your framework more successful.

If you look at the MVC's that have been mentioned here (e.g. Zope, Cake, etc.) they all started around roughly the same time when there were no MVC's for PHP, and you see that they all have their own strengths and weaknesses because the developers who created them don't have an equal passion for all facets of their framework.

I say, we're standing on the shoulders of giants anyways, we might as well admit it, incorporate their work into ours, and be honest with ourselves and the world.

-C

C.J. Steele