CodeIgniter Forums
Controllers...plural or singular? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Controllers...plural or singular? (/thread-21905.html)



Controllers...plural or singular? - El Forum - 08-24-2009

[eluser]jleequeen[/eluser]
Hi Everyone,

I know this is probably pretty individual, but is there a good rule of thumb when deciding whether to use plural or singular controller names? I've seen it done both ways. I don't really have an issue with naming my models and views. To me, a model should be singular, and views well, they are obviously singular based upon the action. I've always struggled with controllers though. I've read that since controllers tend to be "resources" within your application or a collection of objects, that they should be plural. But then I see examples where that isn't the case (ie. blog controller anyone?). Any thoughts on the subject?


Controllers...plural or singular? - El Forum - 08-24-2009

[eluser]Flak[/eluser]
I use singular, looks more logical to me, but depends on what controller, so I will call Blog but Members instead of member. But there is no mistake.

having /member/flak and members/flak its not a big deal. Smile


Controllers...plural or singular? - El Forum - 08-24-2009

[eluser]jedd[/eluser]
Singular all the way.

People who use plurals for these things tend to be a bit odd, and not get invited to many parties.

Don't be one of those people.


Controllers...plural or singular? - El Forum - 08-24-2009

[eluser]brianw1975[/eluser]
I base my controller names on how I want the URL to look. I also tend to group "index" pages as plural and detail pages as singular (If the page is going to display more than one record then the controller should be a plural).

To keep the number of files relatively low I use routes to call the necessary controller. Having users/ and user/x in the same controller.

Another way to think about it (at least in my logic) is that a singular name indicates the end of filtering through data, whereas plural names indicate that you are still filtering.

But, to each their own.

Personally, unless you are looking to redistribute your code, I wouldn't worry about it too much.