CodeIgniter Forums
How to arrange the code for website - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to arrange the code for website (/showthread.php?tid=51260)



How to arrange the code for website - El Forum - 04-26-2012

[eluser]Unknown[/eluser]
Hello everyone, I am new one and have been using codeigniter since a few days... Before I did some pages in XHTML et PHP5. My question is - how to arrange the code in appliation>controller for a simple website with about 10 pages? - do we should make many classes (like one for each page) or many functions in the main class? Ant the second thing that doesn't let me sleep is the object way to deal with the database - I use UML to modelise the tables, the relations, and then build the code.
With PHP5 each time i create the list of variables in the page that suppose to use them, now with CI should I put them all in main class? Plese advise and if it's possible send me some examples. Thank you in advance...


How to arrange the code for website - El Forum - 04-26-2012

[eluser]ojcarga[/eluser]
I think the best way is to have one controller for each page cause there you will have the functionality for each one allowing you to have the code ordered and if there is a common functionality for some of them you should use a helper or a library in order to re-use the code.


How to arrange the code for website - El Forum - 04-26-2012

[eluser]InsiteFX[/eluser]
See the news example in the CodeIgniter Users Guide!