Welcome Guest, Not a member yet? Register   Sign In
Helper Library Plugin - Explain
#1

[eluser]Yash[/eluser]
Hi,

Helper ??

Library ??

Plugin ??

View - Client side part

Model - Used for database query[s]

Controller - site architecture

Can anyone help me to understand when we know that this should be kept as helper/plugin/library.

Thank you
#2

[eluser]Pascal Kriete[/eluser]
Libraries, helpers, and plugins are used for code that you need in different parts of your applications. The same way that you use the native libraries and helpers throughout the app.
#3

[eluser]Yash[/eluser]
No my question is when we know that this code is part of helper or library.

Is there any special rules or whatever author feels is right?
#4

[eluser]Pascal Kriete[/eluser]
Do what you feel is right.

I personally put a lot of my code into libraries - keeps the controllers clean. It's also easy to trace because you have the classname right there in the call $this->classname->function(), that isn't the case with helpers. My helpers tend to be very general, whereas my libraries have a much more defined purpose.
#5

[eluser]nmweb[/eluser]
Also, models are not used solely for database queries. From Wikipedia:
Quote:Model
The domain-specific representation of the information on which the application operates. Domain logic adds meaning to raw data (e.g., calculating whether today is the user's birthday, or the totals, taxes, and shipping charges for shopping cart items).
Many applications use a persistent storage mechanism (such as a database) to store data. MVC does not specifically mention the data access layer because it is understood to be underneath or encapsulated by the Model.
View
Renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes.
Controller
Processes and responds to events, typically user actions, and may invoke changes on the model.
Models encapsulate the data access layer. So, you ask the model to give you the last ten articles and the model gives them to you, you don't have to know where the articles are stored and how, might be a database, text file, session or rss feed etc.
#6

[eluser]Bramme[/eluser]
I personally put lots of stuff in models. Mostly stuff that has to do with the database etc, but also $_POST handling...

Like inparo I only use helpers for very general smaller things I would need over different applications. I use models for bigger stuff which is application dependent and libraries are, like helpers, for things you could use on different applications but which need a tad bigger approach, like a small auth library I wrote myself...
#7

[eluser]Yash[/eluser]
great inputs..thanx a lot guys
#8

[eluser]nmweb[/eluser]
$_POST handling should be done by the controller, but typically $_POST should just be forwarded to the model. The model should have no awareness of it being $_POST or just a random array.
#9

[eluser]Yash[/eluser]
nah.. we don't need $_POST

you can directly access input values using input class
#10

[eluser]nmweb[/eluser]
Point still stands. Models should not access user input directly through either $_POST or the input class, user input is passed from the controller to the model.




Theme © iAndrew 2016 - Forum software by © MyBB