Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save/redirect output from Laravel 5 Artisan command?

I have tried the method described here but this doesn't work on my Laravel 5 installation.

use Symfony\Component\Console\Output\BufferedOutput;

Route::get('/test', function()
{
    $output = new BufferedOutput;

    Artisan::call('testCommand', array(), $output);

    return $output->fetch();
});

My command;

public function fire()
{
    $this->info('No output visible');
}

Any suggestions what I might do wrong? Or is it something that has changed in Laravel 5?

like image 288
Erik Verheij Avatar asked Feb 22 '15 20:02

Erik Verheij


1 Answers

I managed to get this to work using Artisan::output(), which returns the output of the latest command.

Route::get('/test', function()
{    
    Artisan::call('testCommand', array());

    return Artisan::output();
});

should do it for you.

like image 182
sgtdck Avatar answered Sep 30 '22 21:09

sgtdck