Laravel: Return a value from App::call()

I'm going on a limb here; I'm trying to direct a long running script to Artisan. Is it possible for App::call() to return a string value or maybe even send an email once the long running script finishes?

I'm trying to look for more info on this, but is it right to assume that if Artisan is running I can redirect the user to something like a waiting page, maybe a looping gif?

Answers


Use Queue::push() with an appropriate driver (database, perhaps) to push the long-running job to a queue.

The last thing the long-running job should do is send some indication that it's finished.

Here's some sample code:

Queue::push(function($job) use ($id)
{
    Artisan::call('my-command', ['arg1', 'arg2']);

    $job->delete();
});

// Then at the end of your my-command script:
$jobModel = LongRunningJob::find($id);
$jobModel->finishedDate = Carbon::now();
$jobModel->save();

Of course you can then poll the database to determine whether the long-running command has finished.


Need Your Help

Scanning File with String and int Java

java split delimiter scanning

So i have a .dat file that is a list. Each line starts with a letter as a command for my alarm clock program and some are followed by numbers in time format (XX:XX). I need to scan the letter arr[0...