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

I tried the method described here but this does not 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 team;

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

Any suggestions what can I do wrong? Or has this changed something in Laravel 5?

+8
php laravel laravel-5 artisan
source share
4 answers

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

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

should do it for you.

+6
source share

I did it

 php artisan your:command >> output.txt 

worked fine for me.

+4
source share

I had the same problem replacing BufferedOutput with oldschool PHP and it made me work, maybe this works for you too:

 Route::get('/test', function() { ob_start(); Artisan::call('testCommand'); $output = ob_get_clean(); return $output; }); 
0
source share

If you work outside the command line, you can pass the tee command to write to the file and stdout at the same time.

 php artisan <command> | tee <filename> 
0
source share

All Articles