Welcome Guest, Not a member yet? Register   Sign In
Need tips about large CI app
#8

[eluser]tonanbarbarian[/eluser]
while there is no really hard and fast rules about how MVC should be used generally you build your models as representing a database table, or similar entity.
Then you usually have a controller that performs the main actions needed for that model.

So if you have an articles table in the database you create a model called article and a controller called articles.
The controller may need to load other models to help with the management of the articles but that is ok.
However there can be situations where things do not fit that neatly.

Another thing you might want to consider on very large projects is performance. If you have a controller that has a large amount of code in it you might want to break it into several smaller controller. The reason for this is that PHP has to initially parse all of the code before it decides what is actually run, and it will have to allocate memory to store all of the code in etc etc

In this situation what I do is actually strip all of code out of the various methods and put them into seperate libraries.
The controller ends up still having all of the methods in it but each method just loads a library to do its action

For example lets say your 4000+ line controller consists of about 40 methods with nearly 100 lines of code in each method.
If you take each 100 line method and put it into its own Library you can rewrite the controller down to maybe just 100 lines of code.

Code:
class Something extends Controller {
  function index() {
    $this->load->library('SomethingIndex');
    $this->somethingindex->index();
  }

  function show() {
    $this->load->library('SomethingShow');
    $this->somethingshow->show();
  }

  ...
}


Messages In This Thread
Need tips about large CI app - by El Forum - 12-06-2007, 03:36 AM
Need tips about large CI app - by El Forum - 12-06-2007, 04:10 AM
Need tips about large CI app - by El Forum - 12-06-2007, 05:03 AM
Need tips about large CI app - by El Forum - 12-06-2007, 05:58 AM
Need tips about large CI app - by El Forum - 12-06-2007, 06:15 AM
Need tips about large CI app - by El Forum - 12-06-2007, 07:02 AM
Need tips about large CI app - by El Forum - 12-06-2007, 07:43 AM
Need tips about large CI app - by El Forum - 12-06-2007, 01:53 PM
Need tips about large CI app - by El Forum - 12-07-2007, 01:48 AM
Need tips about large CI app - by El Forum - 12-07-2007, 02:18 AM
Need tips about large CI app - by El Forum - 12-07-2007, 02:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB