title: How to sleep PHP(Laravel 5.2) in background
body: <p>I have created an <code>artisan command</code> that I want to run immediately after a method called. But the command contains a <code>sleep();</code> command. I want to run that <strong>artisan command in background</strong> because the method need to <code>return</code> immediately response to user. My sample code is a below: </p>
  
  <p><strong>In route file</strong></p>
  
  <pre><code>Route::get('test', function(){
      Artisan::queue('close:bidding', ['applicationId' =&gt; 1]);
      return 'called close:bidding';
  });
  </code></pre>
  
  <p><strong>In <code>close:bidding</code> command</strong></p>
  
  <pre><code>public function handle()
      {
          $appId = $this-&gt;argument('applicationId');
          //following code line is making the problem
          sleep(1000 * 10);
          //close bidding after certain close time
          try{
              Application::where('id', $appId)-&gt;update(['live_bidding_status' =&gt; 'closed']);
          }catch (\PDOException $e){
              $this-&gt;info($e-&gt;getMessage());//test purpose
          }
          $this-&gt;info($appId.":  bid closed after 10 seconds of creation");
      } 
  </code></pre>
  
  <p><strong>Problem</strong> 
  When I hit <code>/test</code> url the return string <code>called close:bidding</code> is being shown after 10 seconds browser loading, because there is a <code>sleep(10 * 1000)</code> inside the command. </p>
  
  <p><strong>What I want</strong> 
  I want to run the command in background. I mean when I hit the <code>/test</code> url it should immediately show up the <code>called close:bidding</code> but <code>close:bidding</code> command will be running in background. After 10 seconds it will update the application though the front-end user won't notice anything anything about it. </p>
  
  <p><strong>Partial Questions</strong></p>
  
  <ol>
  <li><p>Is it somehow related to <code>multi threading</code>?</p></li>
  <li><p>Is it something that cannot be solve using PHP, should I think differently?</p></li>
  <li><p>Is there any way to solve this problem even using Laravel queue?</p></li>
  </ol>