title: Laravel - call Artisan command and wait for the result
body: <p>I'm trying to call in a controller a very time-consuming Artisan command (it executes in 20-90 s ), but I have two problems. First of all it seems like the command does not execute at all (if I return the output it just returns "0").</p>
  
  <p>Secondly the other part (returning the file) does not wait for the command to execute (but it can be related to the first part). Here's my code:</p>
  
  <pre><code>public function returnZip()
  {
      // just a failsafe, in case if scheduled command did not created the file yet
      if( ! file_exists( storage_path( '/app/exports/' . date('Y_m_d') . '.zip' ) ) ){
          Artisan::call('maximus:export');
      }
  
      return response()-&gt;file( storage_path( '/app/exports/' . date('Y_m_d') . '.zip' ) );
  }
  </code></pre>
  
  <p>How can I properly execute the Artisan command from route/controller and wait for it to finish it's task?</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>I tried to debug this problem a little more and found out that the command is not being executed at all when called from a route/controller. </p>
  
  <p>Tried this: </p>
  
  <pre><code>Route::get('/test', function(){
      Artisan::call('maximus:export');
      return ['ok'];
  });
  </code></pre>
  
  <p>And my command is supposed to create a file:</p>
  
  <pre><code>public function handle()
  {
      exec('touch /some/path/storage/app/exports/test');
   }
  </code></pre>
  
  <p>When I run this command in terminal, the file is being created, but when I hit the route, it isn't. Any ideas? </p>