I have bad news for you, that is not possible. The confirm method will wait for a confirmation from the prompt and not from the Laravel application. So it will wait on use interaction, but you can't fake that from a PHP application as far as I know.
Jun 11, 2017
5
Level 10
Laravel console Auto confirm after sometimes
Hi,
I'm running onto a problem, I have the code:
// https://laravel.com/docs/5.4/artisan
if ($this->confirm('Do you wish to continue?')) {
// I might not at the computer at that time, after 10s of no interaction, please just continue ( yes or y )
}
I wrote a wrapper console app and want to have feature like above, how can I achieve that?
Thank for reading this guys :).
Level 10
Thank god, there is workaround, I've invest too much to write from scratch
echo "input something ... (5 sec)\n";
// get file descriptor for stdin
$fd = fopen('php://stdin', 'r');
// prepare arguments for stream_select()
$read = array($fd);
$write = $except = array(); // we don't care about this
$timeout = 5;
// wait for maximal 5 seconds for input
if(stream_select($read, $write, $except, $timeout)) {
echo "you typed: " . fgets($fd) . PHP_EOL;
} else {
echo "you typed nothing\n";
}
Please or to participate in this conversation.