Jump to content

Server Side Program to call PHP processes


ExpertAlmost

Recommended Posts

Good morning!

 

I need a control program that runs continuously on the server and waits for a time/date/file-found trigger to initiate one of several PHP processes. Each PHP process being initiated requires one or more input variables from the control program: My_PHP_Program(Var1, Var2, Var3). No user/client-side calls (no forms) are made with no HTML output being produced. Each PHP process just generates files which are later accessed by user/client-side page calls in the usual manner.

 

Can someone provide me with code examples/pointers? (I am assuming that my host site will run Unix/Linux but I will also want to test this locally on my WinXP Apache server.)

 

Pseude-code example:

 

My_Control_Program waits for new hour to begin then

  On Hour: My_Control_Program calls PHP program: Collect_Data(HourData) to collect hour data and generate a new file: NewHourDataFile

My_Control_Program checks every minute for NewHourDataFile

  When NewHourDataFile exists, My_Control_Program calls PHP program: Build_Graphics(NewHourDataFileName) to generate new hour graphics for all users.

My_Control_Program waits/checks ...

 

Thank you everyone!

Link to comment
Share on other sites

There's nothing much to this.  Right the individual scripts that perform the individual functions you need.

 

There's a command line php client you should be able to use to call the scripts.

 

The scripts can be called on the required schedule via cron (on linux).  Cron is very flexible in that it can be set to run hourly, daily, every minute, etc.  whatever you need. 

 

Truthfully I'm not a big fan of Wamp, however you can simulate the same idea using php.exe and the windows scheduler.  A much better solution for development of apps that you need to run under linux, is to use virtualization like sun virtualbox or vmware workstation, install a linux distro, and do your testing in the virtual machine. 

Link to comment
Share on other sites

Thank you gizmola!

 

That is helpful. One thing I cannot figure out however is how to include input variables when I do not have a POST/GET/FORM from the client?

 

For example: my_php_program(var1,var2,var3).php

 

The cron examples I find just have my_php.php. Calls the program but no inputs...

 

Thank you again :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.