Welcome Guest, Not a member yet? Register   Sign In
Controllers, Helpers
#1

[eluser]Unknown[/eluser]
Hello, so I'm not exactly sure when I've written a piece of code whether it should be a helper or a controller. Let me give you an example: I'm currently writing a library script that will organize my eBooks. It opens the pdfs, finds the ISBNs (or EANs), asks Amazon for information, then stores everything in a database, etc...

Earlier I wrote the set of functions to query Amazon as a unique class because, well, that just seemed to make sense. It made the queries ridiculously easy.

I did the same with the pdf processing functions. The classes would work in tandem so that I would instantiate an object, give that object a directory, and then the pdf would be processed an call amazon itself, returning all of the data in a nice little array to work with.

I now want to port these classes to CI, but I can't figure out how to do so. On some level they seem like they should be helpers because they seem to have that purpose, but, unfortunately, I can't use the objects the same way if they are helpers. The classes are normally controllers, but I'm not sure if they would play nice with each other as separate controllers, but it doesn't make sense to combine them.

On another level altogether, it would make sense to make them into libraries, but, well, that seems to elevate them above their proper status.

So, my question is what would you do with these things? Controllers? Helpers? Libraries? I know that they shouldn't be models. But...

-a
#2

[eluser]Rey Philip Regis[/eluser]
Hi,

As for me I will create them as libraries not helpers and not controllers. My first reason why not helpers is because helpers is not OO and also helpers are only used for small tasks. Also I will not use it as controller cause the controller controls the logic of you application, its only there to facilite and control the data. That's what I think.

Good day.
#3

[eluser]Colin Williams[/eluser]
PHP Class = Library. Library = PHP Class
#4

[eluser]Rey Philip Regis[/eluser]
Quote:PHP Class = Library. Library = PHP Class

Short but exact..
#5

[eluser]Unknown[/eluser]
And helpful! Thanks to you both.

-a




Theme © iAndrew 2016 - Forum software by © MyBB