Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get response from Artisan call

When I run in terminal php artisan migrate this results in 'Nothing to migrate' when indeed there is nothing to migrate.

When I use Artisan::call('migrate') in code (use this in a custom Artisan command) this doesn't return any message. It just executes the code without any feedback.

If I vardump() the result of the Artisan::call method it just returns an int(0)

Is it possible to get the response of the Artisan call method?

like image 543
cenob8 Avatar asked Mar 18 '14 16:03

cenob8


Video Answer


2 Answers

For me with Laravel 5.1 all this did not work but you can simply use:

Artisan::output()
like image 67
PiTheNumber Avatar answered Sep 17 '22 19:09

PiTheNumber


I'm able to get the output of Artisan::call() with the via the following:

use Symfony\Component\Console\Output\StreamOutput;

$stream = fopen("php://output", "w");
Artisan::call("migrate", array(), new StreamOutput($stream));

var_dump($stream);
like image 33
George Huber Avatar answered Sep 21 '22 19:09

George Huber