title: Run PHP script like an application without Browser
body: <p>Hi I am new to PHP and have no idea if what I am about to ask is even possible or does it even make sense but here goes.</p>
  
  <p>I want to execute a PHP script as if I am executing a standalone application on the WebServer, what I am trying to implement is that when the Customer purchases something on the website and the once he sees the payment confirmation notice on the website, he should be allowed to close the browser window or logoff without affecting the big order generation process that get's started once the user is taken to the page that displays that the payment that he made was successful.</p>
  
  <p>Right now I am making use of AJAX to call my after payment processing PHP script and have kept that script to ignore any user abort call.</p>
  
  <p>This is the page that tells the user that the payment was received successfully.</p>
  
  <p><strong>thankyou.php</strong></p>
  
  <p>This is the page that performs the processing that needs to be done only after successful receipt of payment</p>
  
  <p><strong>FinishCheckoutProcess.inc.php</strong></p>
  
  <p>Now <strong>thankyou.php</strong> makes use of AJAX to execute <strong>FinishCheckoutProcess.inc.php</strong> asynchronously and <strong>FinishCheckoutProcess.inc.php</strong> has a PHP.ini setting in it that goes like this:
  ignore_user_abort(true);</p>
  
  <p>Now the combination of AJAX and ignore_user_abort(true) allows the after payment process to run without any errors even if the user closes his browser window, but since this script has nothing to do with the user or the browser I just wanted to know if it is possible to run this script in the background like a standalone application independent of the browser.</p>
  
  <p>Also my WebServer is Apache and OS is Linux(Ubuntu OS).</p>
  
  <p>My work is getting done but I just want to know if there is a better/safer way to do it.</p>
  
  <p>Anyway thanks in advance to everyone, this site has helped me more than any book could have. So all you experts out there who donate their times to newbies like me you guys are awesome. Please keep up the good work.</p>
  
  <p>Again thanks a lot.</p>
  
  <hr>
  
  <p>Based on suggestions received
  If I use the "exec" method to execute the FinishCheckoutProcess.inc.php, will this execute database related commands and will it be able to run further PHP scripts.</p>
  
  <p><strong>FinishCheckoutProcess.inc.php</strong> in turn executes a series of other PHP scripts which in turn executes other PHP scripts, so will using "exec" command to run FinishCheckoutProcess.inc.php create any difficulties.</p>
  
  <p><strong>FinishCheckoutProcess.inc.php</strong> process <strong>also does interaction with the MySQL database</strong>, so will I be able to do this if I execute this script using "<strong>exec</strong>" command. I am passing the necessary MySQLi connection object to this PHP script right now. So can I pass it the same way to it using "<strong>exec</strong>"</p>
  
  <p>Also the process is quite heavy as it generates a set of 4 image files using <strong>IMagick</strong> and <strong>ImageMagick</strong>.</p>
  
  <p>It generates a set of 4 image files for every product ordered, so if the quantity of 1 product is 10 then the total files generated will be 1x10x4 = 40</p>
  
  <p>If there are two products with one having quantity as 2 and the other having quantity as 4 then the total files generated will be
  1x2x4 = 8 +
  1x4x4 = 16 = 24</p>
  
  <p>So this script might need to run for a long time and cannot be allowed to be stopped due to time out reasons, it needs to finish what it started.</p>
  
  <p>Basiclly the <strong>FinishCheckoutProcess.inc.php</strong> logic and process is quite complex so just want to confirm if the "<strong>exec</strong>" can handle it or not.</p>
  
  <p>Also I am not sure but some of them also make use of $_SESSION variables, but if this a problem I can modify it, $_SESSION variables only get's used in one place and yes the $_SESSION get's set in the browser before the <strong>FinishCheckoutProcess.inc.php</strong> script is executed. By some previous PHP script.</p>
  
  <p>I just want to execute the <strong>FinishCheckoutProcess.inc.php</strong> script independent of the parent/calling script i.e. <strong>thankyou.php</strong>, so that if the user closes the browser then the <strong>FinishCheckoutProcess.inc.php</strong> will not stop or abort becuse the parent/calling script i.e. <strong>thankyou.php</strong> is now no longer running.</p>