tags:

views:

167

answers:

5

I'm totally new to mvc,how to pick it up?

A: 

First research the MVC pattern and look for tutorials that explain how to implement it. Next, get an MVC framework for PHP and use that since there's no sense trying to reinvent the wheel and roll your own.

Soviut
Actually I think MVC is a simple enough concept that you can do it yourself. Frameworks add a variety of bloat (some not much and some a lot), which may or may not be useful and may or may not confuse the issue.
cletus
It's not easy to roll your own either.... not for a beginner anyway. I don't think a framework would hurt too much... they're good to learn too.
Mark
MVC in itself is simply. Frameworks made it complicated. Not to mention that in the PHP land, MVC usually means a Front Controller, a Router and a Template engine too. That's why is so hard for beginner to grasp it.
Ionuț G. Stan
Not true, frameworks get rid of a lot of boilerplate code. For example, url routing, dispatching, a view template language, etc.
Soviut
+2  A: 

Go this way:

  • Know what is MVC
  • Why it is useful
  • How does it work
  • Where it should be used optimally
  • How do frameworks use it (if possible to know)
  • Learn how frameworks implement it (try using a framework)
  • Learn a framework so that you can become habituated to using MVC

I know I might sound foolish, but this way can be of great help to newcomers.

Manish Sinha
+3  A: 

Go this way:

  1. Read about MVC (Google it, see the wikipedia article)
  2. Choose a Framework (I suggest CodeIgniter - Has a great user guide)
  3. Then go through the user guide and try the things.

The video tutorials are also good, check nettuts.com for CI.

Geshan
+1 for CI mention....love it love it love it
espais
CakePHP is a great PHP MVC framework as well. I found it much more malleable than CodeIgniter, but CI may have matured a lot since I last tried it several years ago.
Matt Huggins
What's CI?I never heard of it.
Mask
CI = CodeIgniter
Michal M
CI = CodeIgniter = Great and amazing documentation.
Geshan
+1  A: 

Maintain some project written in spaghetti code (CSS + JS + HTML + PHP + SQL, all in one single file), then think how you would separate all these and you'll discover MVC.

Kidding aside. Read about it what you can, try some framework but don't avoid maintenance projects. It is in these projects that you'll see the benefits of MVC or at least those of separation of concerns.

See also this related question.

Ionuț G. Stan
+1  A: 

You can read all about MVC with a simple google search. However, you won't fully understand the beauty of it until you pick a framework and dive in. I hear great things of CodeIgniter. It was my first framework when getting into MVC.

In the end I chose CakePHP. Why? CodeIgniter, while very simple to get started with, gave me too much freedom for a beginner to MVC. I wanted strict rules and conventions to show me how its supposed to be done rather than what I think MVC should be. Maybe later on down the road I'll come back to CI. Either way you choose, my suggestion is to take a small project you coded, and code it in any of the PHP frameworks out there.

CakePHP's and CodeIgniter's communities are among the most helpful. Join a google group for Cake/CI. Read about what people are trying to do. See what problems people are having and good luck!

centr0