tags:

views:

45

answers:

3

how do you trigger a MVC application.

im only used to use procedural coding. since everything are classes, how do i trigger the first method, where should this method be put, and what should the class holding this starter method be called?

thanks

+1  A: 

This is too general of a question. The answer will be subjective, because it can be done in many different ways. Your best bet is to look at a simple, lightweight MVC framework, see how they did it, and use that as a guide. I recommend checking out LightVC.

Generally all requests are routed through an index.php file. The request url is inspected to figure out what class file to include. For example, a request to /users/login would fire up Users_Controller, and then it would execute the login() method on the Users_Controller class. This is how most frameworks do it, but like I said, you should look at their source to get a better feel.

ryeguy
A: 

Remember an MVC application is like a website, so when the user visits a page in their browser, it will call the methods automatically associated with that page, in the Controller.

SLC
I can see where he's coming from, if you're new to web development it can be a little confusing, especially one as decoupled as MVC
SLC
+1 for thinking from my perspective.
never_had_a_name
Wonder who gave me -1
SLC
i always wonder that too:)
never_had_a_name
+1  A: 

MVC applications have routers which based on the URL will call the appropriate controller and function inside.

Take a look at the flowchart of CodeIgniter for example - http://codeigniter.com/user_guide/overview/appflow.html

Ivo Sabev