I am trying to run a PHP script in the background after getting the 200 respond from apache, however, it is not working, am facing a little problem with the following code and I am not sure why.
<?php
ignore_user_abort(true);
set_time_limit(0);
ob_start();
header('Content-Type: application/json');
// output the array to screen
echo json_encode(['data' => 'foo']);
header('Connection: close');
header('Content-Length: ' . ob_get_length());
ob_end_flush();
ob_flush();
flush();
// run the rest of the code in background
I am getting the status code 200, but after the full script process is done, the script it outputing the json array above. Any thoughts?