laravel / prompts

Beautiful and user-friendly forms for your command-line PHP applications.

Home Page:https://laravel.com/docs/prompts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't hit enter in text input

philharmonie opened this issue · comments

Laravel Prompts Version

0.1.17

Laravel Version

10.48.4

PHP Version

8.2.16

Operating System & Version

macOS 14.2.1

Terminal Application

phpStorm 2023.3.35

Description

I can't hit enter to confirm a text input.
I already tried to rm -rf vendor && composer install && composer clear-cache && composer dump-autoload without success

Steps To Reproduce

Run e.g. artisan make:controller and enter the controller name.
When hitting enter, nothing happens.

Hey @philharmonie, I don't have macOS or PhpStorm to test this, but I feel like this would have already come up before if it occurred in a typical configuration. I'm wondering whether there's a terminal setting that's changed how the Enter key is received in PHP.

To test this, could you please create a file (e.g. test.php) with the following contents:

<?php

$initialTtyMode = `stty -g`;

`stty -icanon -isig -echo`;

while ($keys = fread(STDIN, 1024)) {
    echo json_encode($keys).PHP_EOL;

    if ($keys === "\x03") {
        `stty $initialTtyMode`;

        exit(0);
    }
}

And then execute that file in the problematic terminal:

php test.php

It should echo out each key as you press it, so could you please press the Enter key and report the result? You can use Ctrl+C to exit when you're done.

Could you also please confirm whether or not this happens in another terminal application (e.g. the default macOS terminal or iTerm).

It prints \n and in the default macOS the issue does not occur. But in general the enter key is working in the phpStorm terminal.

That's really strange. \n is the character we look for to detect an Enter keypress, so I can't think of any reason why Enter wouldn't be detected. The script I gave you emulates everything Prompts does to detect keypresses.

Can you confirm whether the issue occurs in a fresh Laravel installation?

In the meantime there is a new update for phpstorm and the issue vanished. Still weird, but for me: resolved