Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

regularlabs's avatar

How to run Command with command line output from Seeder?

Inside Console/Commands/UpdateStuff.php I have a bunch of feedback lines, like:

$this->line('Updating stuff...');

When I run php artisan update:stuff all works fine and I see the 'Updating stuff...' line in the console.

But now I want to run this from a seeder.

So inside FooBarTableSeeder I have:

Artisan::call('stuff:update');

When I run php artisan db:seed --class=FooBarTableSeeder the Command is executed. But there is no output to the console.

So question: How can I make the Command output to the $this->command of the Seeder?

0 likes
3 replies
veganista's avatar

A bit late to the party here but you can do this:

$this->command->line('Updating stuff...');

From your Seeder class

8 likes
jivanf's avatar

Artisan::call() has a parameter called outputBuffer. We can pass the output instance of the seeder command to the called command through this parameter like this:

// In the seeder's `run()` method...
Artisan::call(command: 'stuff:update', outputBuffer: $this->command->getOutput());

By doing this, the called command will not use its own output instance to show output, but rather the seeder command's instance. This allows us to see the output of both commands.

Please or to participate in this conversation.