Use $this->components property within commands
use Illuminate\Console\Command;
class CommandWithComponents extends Command
{
public function handle()
{
- $this->ask('What is your name?');
- $this->line('A line!');
- $this->info('Info!');
- $this->error('Error!');
+ $this->components->ask('What is your name?');
+ $this->components->line('A line!');
+ $this->components->info('Info!');
+ $this->components->error('Error!');
}
}
Configure your rector.php
:
<?php
use RectorLaravel\Rector\MethodCall\UseComponentPropertyWithinCommandsRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
UseComponentPropertyWithinCommandsRector::class,
]);