User Uploads Image. After this step you can create a task. One Taks - one row of the task table in your database.
class Task { const STATUS_PENDING = 'pending' const STATUS_ERROR = 'error' const STATUS_FINISHED = 'finished' private $userid; private $taskData = array(); public function run() {
On the server side, you should think about how to work / organize your tasks. It depends on your needs. With the power of TaskManager, you can control your process. It is very important that not 100 processes run in parallel.
Now the client side can easily request a task table with a user ID to verify the pending task. If the status is completed or an error, you can give the user excellent feedback. You can poll this information every five seconds. The interval depends on your needs. Polling for five seconds may be odd for your browser. Itβs a good idea that the client receives the status instead of the server, sends the status to the client. If it is important that the server sends status, you should use web sockets. The backend may be the same.
Here is a simple survey example.
setInterval(function(){ $.ajax({ url: "server", success: function(data){
proc_open is only good if you have some additional options. With the power of proc_open (pay attention to the pipes) and in combination with stream_set_blocking. You can write asynchronous task processing. If you do not need a special exec , that will be enough.
Here is an example without locking.
class Task { private $process = null; private $pipes = array(); private $status = 'pending' public function run() { $descriptor = array ( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w") ); $cmd = "/path/to/progam --with --some-arguments" $this->process = proc_open($command, $descriptor, $this->pipes); stream_set_blocking($this->pipes[1], 0); } public function close() { foreach($this->pipes as $pipe) { fclose($pipe); } $exitStatus = proc_close($this->process); $this->process = NULL; return $exitStatus; } }
Hope this gives you some inspiration to solve your problem. For real message queues, you can use what you want. I am a fan of http://kr.imtqy.com/beanstalkd/ Now I will focus on solutions and ideas, because this question is more complicated, and I can write another 100 pages. If you have questions about konkrete, you can delete the line.