CodeIgniter Forums
controller action run 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: controller action run external php file (/showthread.php?tid=20352)



controller action run external php file - El Forum - 07-07-2009

[eluser]dimis[/eluser]
I want when a action of a controller finish , this action to run a file at the root of my application.How can I do this?
Dimis


controller action run external php file - El Forum - 07-07-2009

[eluser]Dam1an[/eluser]
If you want this to happen at the end of every request, you could use a post system hook, or if using PHP5, you could put a __destruct function in MY_Controller

You can just execute the function by including it (if it's written as a class, you will need to add some code to instantiate the class)

You can use the APPPATH constant to build the include path


controller action run external php file - El Forum - 07-07-2009

[eluser]dimis[/eluser]
Maybe I were not clean.
I have a file (torun.php for example) at the root of my site that it is a clean php file and it has nothing related with codeigniter application (it is a cron file that runs independent from Codeigniter).
And I want this file to run within an action of a controller (omly one).
CI can not run a simple php file ?I have to "include" this file?How?


controller action run external php file - El Forum - 07-07-2009

[eluser]Dam1an[/eluser]
You literalyl just answered your question
Code:
include APPPATH.'torun.php';

Just put that at whatever point you want it to be called, and it will go off and run that, and when it finishes, return to that point in the controller and carry on