Calling a Controller Function from an External PHP File? |
[eluser]Vik[/eluser]
Is there a way to call a function in a CI controller, from a PHP file that is not part of the CI app? Note - this is part of my effort to integrate a Simple Machines Forum board, with my CI app. Thanks in advance to all for any info.
[eluser]gunter[/eluser]
maybe you can try this, but I have never heard of someone who has used it http://codeigniter.com/wiki/dip_into_CI/
[eluser]Vik[/eluser]
I'm going to see if the code from this page does the trick - [email=http://www.bin-co.com/php/scripts/load/]PHP Load function[/email].
[eluser]Negligence[/eluser]
Try this. Code: include('path/to/controller.php');
[eluser]Vik[/eluser]
Thanks for the suggestion, Negligence. This will be cool if it works. I have to include a lot of stuff to define the controller class. Here's what I've got so far: Code: $system_folder = "system"; On the line: Code: $controller = new Controller(); ...I'm getting the following error: Quote:Debug Error: system/libraries/Controller.php line 74 - Call to undefined function load_class() I.e. there's a call to load_class in Controller.php, line 74, that PHP says is undefined. (I'm using PHP 5, so the call to load_class in my code isn't getting executed.) Where does function load_class get defined? I can't find it yet in the PHP manual _or_ the CI manual! ![]()
[eluser]Vik[/eluser]
It just occurred to me that, even if I get this approach working, I won't have access to all the variables produced when CI is run, because, I won't have actually started CI - I'll just be running a class method. Hmmm...... It looks like FreakAuth author Grahack has developed an approach to this, which he describes in this forum thread. |
Welcome Guest, Not a member yet? Register Sign In |