When using the method Command::choice()
I get a weird response with random characters and question marks (I believe those are ansi escape codes). This only happens on Windows (As far as I have tested).
I ran into this issue on two Win 10 Pro installs. Installed US-En as the default language.
I ran the same script on Ubuntu and macOS and it ran with no issues at all. It prompts the user with the two options, chooses one, and does whatever next.
To test if this was only on CMD I ran the command on Hyper and PowerShell as well, getting similar results.
CMD
PowerShell
Hyper
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class TestChoice extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test:choices';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$color = $this->choice('Which color do you prefer?', ['blue', 'red']);
$this->info("Your favorite color is $color");
}
}
Has anyone run into this issue? Or what steps can I take to resolve this issue?