Welcome Guest, Not a member yet? Register   Sign In
Splitting one controller into multiple files
#1

[eluser]xzela[/eluser]
Is there a way to split a single controller into multiple files?

I would like to start splitting a particular controller I'm working with into smaller pieces because it's starting to become rather large.

Here is an example of what I would like to achieve:

I have two urls:
Code:
http://localhost/junk/foo/1

http://localhost/junk/bar/1

These urls relate to the same controller 'junk'. But what I would like to do is be able to split the controller into two files so that foo and bar are not in the same file.

Does anyone know if this is even possible? or, is this the wrong way to go about it and large controllers are normal?
#2

[eluser]Mark Skilbeck[/eluser]
Most languages acheive this with 'namespaces', although I don't think it's implemented in PHP or CI yet.
#3

[eluser]Xeoncross[/eluser]
ya, just do it.

We had a controller here recently that actually split into 4 other controllers to help speed up the system. Splitting up un-related functionality among controllers makes your system faster.

Take a blog
1) view controller
2) CRUD controller
3) Archive controller
4) etc...

You could put all that in one huge view - but then you would have a HUGE file to load on each request.
#4

[eluser]xzela[/eluser]
But how do you do it within one url? How do you load the extra functions? Do you have any code examples?
#5

[eluser]Xeoncross[/eluser]
Routing
#6

[eluser]xzela[/eluser]
ah....

interesting... Cool, thanks for the help.




Theme © iAndrew 2016 - Forum software by © MyBB