I have Drupal server with a REST API using services and rest_server (that's just background, I don't THINK that applies to this problem at all.) I'd like particular API calls to only report back that the request was received, but then go on to do further work in PHP.
To me, this seems like a thread/fork solution, but I can't seem to find a viable solution using PHP/Drupal. The first (and from the looks of it, easiest) thing I came across was the pcntl_fork() function. But, as it looks like that's not viable:
It is not possible to use the function 'pcntl_fork' when PHP is used as Apache module. You can only use pcntl_fork in CGI mode or from command-line.
Using this function will result in: 'Fatal error: Call to undefined function: pcntl_fork()'
(And, indeed, when I try using function_exists() through command line, it's there, but when run in PHP through Drupal it says function is undefined. I'm reading some stuff on how to install it/recompile PHP with it, but would prefer if there were a method that didn't involve changes to the server.)
Other than that, I'm coming across solutions such as creating a queue to run with cron jobs, creating convoluted menu items, or a whole background processes... thing. All I want is for some arbitrary code to be run off on its own. Does anyone have a suggestion that they feel works best with with Drupal?
(Also, I don't know what to tag this as--I tried thread or asynchronous but those don't seem to exist--so feel free to tag.)