Naming conventions for controllers |
[eluser]ilSignorCarlo[/eluser]
Hi, everytime I start a new project with CodeIgniter I'm not sure about a good practice in organizing the whole project. For example, how do you usually choose the name for a controller? Is it a good habit to name controllers after the site structure? For example: a "home" controller, a "user_profile", "admin" and so on. Almost a controller for every main page of the site. This usually tends to work (at least, for me), but I suppose it is a wrong approach. Can you show me some examples of controller names or of a directory site structure? Thanks, Carlo
[eluser]überfuzz[/eluser]
You can put them into folders. www.site.com/folder/controller/function/etc... The file structure would then be: controllers/folder/controller The sweet part is that you'll reach it without altering anything in CI. If you have set a default controller in routes.php CI will look for the same name in subfloders.
[eluser]ilSignorCarlo[/eluser]
[quote author="überfuzz" date="1260644533"]You can put them into folders. www.site.com/folder/controller/function/etc... The file structure would then be: controllers/folder/controller [/quote] Thanks. I know about the possibility to put them in folders, but still I'm not sure about which may be the better choice for the filename.
[eluser]überfuzz[/eluser]
I always look at the site. What do I want to display, is there going to be secured areas etc. Then naming of the controllers I try to keep as semantic as possible.
[eluser]ilSignorCarlo[/eluser]
[quote author="überfuzz" date="1260645338"]I always look at the site. What do I want to display, is there going to be secured areas etc. Then naming of the controllers I try to keep as semantic as possible.[/quote] Can you be more specific? What do you mean exactly by "keep as semantic as possible"? Some concrete examples?
[eluser]überfuzz[/eluser]
You're really better of with wikipedia than me I guess. At least when it comes to explaining the meaning of words. Example: Let's say there's a page in the website with information of how to get in touch with people associated with the site. Following the idea of semantic naming it could be called contact. |
Welcome Guest, Not a member yet? Register Sign In |