I have a project based on codeigniter. And I should use one class that extended from a codeigniter controller in another php file. But I didn't find the solution about how to teach another php file to see whole CI-project. Beyond that needed class can not inherit when i call it from other place.
Asked
Active
Viewed 1,763 times
0
-
What problem are you trying to solve? Are you trying to bridge two codeigniter instances? – Sean Madden Jan 17 '11 at 19:17
-
Would you mind clarifying your question? It would help to see some example code. – Lance Jan 17 '11 at 20:56
-
I have a PEAR library and run it from the console. This library must use one of my class that extended from the codeigniter controller. And when I call this class library can't see CI-controller. I need to get object of my CI-project like $ci = get_instance();. But it doesn't work because the PEAR library can't see my project. – chch Jan 19 '11 at 17:33
1 Answers
0
I'm not 100% sure if this helps get you in the right direction, but kudos if it does!
Codeigniter routes the application depending on the environment state of the URI. What you need to do is set the environment and include the index view file like so:
$_SERVER["REQUEST_URI"] = "cms/2";
//Set GET action,method params etc
require_once "path/to/index.php";
When you load CI Index file it reads the SERVER Variable and others which you may have to find and execute the controller and method, I would also advise that you modify the library/view file as it may exit upon output causing your script to exit.
Also you may wis hto look into ob_start() to catch the buffer.

Will Ashworth
- 1,058
- 3
- 13
- 28