Welcome Guest, Not a member yet? Register   Sign In
MVC Tutorial - Controllers
#1

[eluser]wiredesignz[/eluser]
Quote:The controller's job is to take the user's input and figure out what to do with it.

source:http://www.martinfowler.com/eaaDev/uiArchs.html

So what is 'user input'?

Considering all basic input to a web application is via http request then user input to a controller must be the via the calling URL and associated http $_ variables.

The Controllers job then is to figure out the incoming request by following the application logic designed by the developer, and to create and send the proper response to this input back to the user.

One important point to note here is that 'application logic' is not the same as 'business logic' and needs to be clarified.

Application logic concerns the flow of the code, based on the information received and conditions that may exist along the way, to finally produce an output.

So we have our controller accepting input from the URL and http variables and have decided what we should do with that information. What next?

In terms of CodeIgniter we have many core libraries and helpers which enable us to manipulate our application to achieve the desired result, and we are able to create our own libraries or even override and manipulate the behaviour of the CodeIgniter core and it's components.

The controller is thus the entry point to your application and the manager of its assets, with a single job to produce a response to user input.

Thanks for reading.
#2

[eluser]Jesse Schutt[/eluser]
Thanks for taking the time to spell this out for us beginners :-)
#3

[eluser]Colin Williams[/eluser]
Um... dead on, wiredesignz. I like how you summed it up:

Quote:The controller is thus the entry point to your application and the manager of its assets, with a single job to produce a response to user input.

At the risk of over-simplifying it, I like to sometimes think of each component of your app, controller, view, models, libraries, helpers, et. al., as a group of people. If you were to walk up to that group and request something, it is Controller's job to step forward, take the information you've brought back to the group, and return with the response based on what the group came up with.




Theme © iAndrew 2016 - Forum software by © MyBB