![]() |
Calling a Controller Function from an External PHP File? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Calling a Controller Function from an External PHP File? (/showthread.php?tid=4708) |
Calling a Controller Function from an External PHP File? - El Forum - 12-11-2007 [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. Calling a Controller Function from an External PHP File? - El Forum - 12-11-2007 [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/ Calling a Controller Function from an External PHP File? - El Forum - 12-11-2007 [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]. Calling a Controller Function from an External PHP File? - El Forum - 12-12-2007 [eluser]Negligence[/eluser] Try this. Code: include('path/to/controller.php'); Calling a Controller Function from an External PHP File? - El Forum - 12-12-2007 [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! ![]() Calling a Controller Function from an External PHP File? - El Forum - 12-12-2007 [eluser]Negligence[/eluser] It's in system/codeigniter/Common.php Calling a Controller Function from an External PHP File? - El Forum - 12-12-2007 [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. |