Welcome Guest, Not a member yet? Register   Sign In
splitting a big controller source file
#1

[eluser]Bad Penguin[/eluser]
My controller has many methods because i dynamically get it called for almost any URL
and this controller have to detect the URL and display different kinds of data.

The controller source code is very big... 3.000 lines.

Any idea how to split it in different sources?

Or any way to call other controllers without doing HTTP redirects?
#2

[eluser]Cristian Gilè[/eluser]
Hi Bad Penguin,

you can't call other controller method without redirect but you can:

- use a base controller (MY_Controller) and extends your big controller
- use a library
- use HMVC (https://bitbucket.org/wanwizard/modular-ci/src)
#3

[eluser]Unknown[/eluser]
I have same scenario in my codeigniter application which also has big controller size. I want to split this controller into manageable modules. And my application is hosted on php 4 server and i can't use modular extension (HMVC), because it runs on PHP5 server.

Then is there any other way to split my bigger source code controller into smaller ones. Please help me in this issue.

Thank you,
Shah Nawaz
#4

[eluser]smilie[/eluser]
Shah, as Cristian already mentioned look into libraries to see if there is anything you could split to libraries (or helpers).

Cheers,
Smilie
#5

[eluser]gyo[/eluser]
Just guessing... would URI Routing help?
#6

[eluser]Bad Penguin[/eluser]
[quote author="gyo / suashi" date="1294263241"]Just guessing... would URI Routing help?[/quote]

No, obiovusly the controller is big because it need to handle first part of the url (usually the class) in a way to detect wich content need to be displaed (out of 20 different models) ... and... $route['static_text'] is not my way too because static_text need to be in MANY languages Smile
#7

[eluser]Bad Penguin[/eluser]
[quote author="Cristian Gilè" date="1294248477"]
- use a library
[/quote]

Probably the best thing is to use a library and call:
static_method($this);

from within the controller?




Theme © iAndrew 2016 - Forum software by © MyBB