How do you run processes in the background while the website runs using php? | Sololearn: Learn to code for FREE!

0

How do you run processes in the background while the website runs using php?

If I want to run any processes in the background while the website runs, do I only need to start that on the index.php page, or all of the pages?

12/3/2017 4:18:54 AM

Scarlett Jones

3 Answers

New Answer

0

@Aditya kumar pandey I have heard that PHP threading doesn't work on web servers and that it is better to fork a new process. But I'm wondering if I only need to start running the process on the index.php page or does it need to be on all the .php pages?

0

@Aditya kumar pandey From the PHP documentation: http://www.php.net/manual/en/intro.pthreads.php "Warning The pthreads extension cannot be used in a web server environment. Threading in PHP is therefore restricted to CLI-based applications only."

0

@Aditya kumar pandey I think I want to use the forking method because I want to have a server listing for connections from multpile clients who will send the server messages. These clients are basically either asking for values or providing the server with measurements. The clients are different lights and sensors. The server will tell them what values they need to be based on some user input on the webpage. Sensor data will be temperature readings and a few other things. The server will determine if the light is getting too hot based on the temperature reading sent to it and will tell the light when to turn on and off a fan.