Reputation: 721
If I run php artisan migrate:fresh --seed --force
in console everything works as expected.
The output is displayed one by one.
Dropped all tables successfully.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Seeding: UsersTableSeeder
etc.
If I run the artisan command from Laravel everything work fine excepting the output. It is displayed once at the end with all of the actions.
$this->info('Migrating and seeding the database...');
Artisan::call('migrate:fresh', [
'--seed' => true,
'--force' => true,
]);
$this->line(Artisan::output());
I am looking for a method to display Artisan::output() one by one for each table (the same behaviour like running the command in console).
Upvotes: 1
Views: 662
Reputation: 40909
The reason why your code works the way it does is that you display the output from the command once it's been completed with:
$this->line(Artisan::output());
In order to display the output of executed migrate:fresh command as it progresses with running the migrations, you need to make it output to the output of the parent command instead of it's own, that's later read by Artisan::output().
The following code will do the trick:
$this->info('Migrating and seeding the database...');
Artisan::call('migrate:fresh', [
'--seed' => true,
'--force' => true,
], $this->output);
Notice the third argument passed to the call()
method.
Upvotes: 3