Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does PHP 7.4 on Windows aborts all command line actions that require user input?

I have a local setup for developing on Symfony 5.0 on 3 different Windows 10 PCs, and all of them have no issue when the PHP version is 7.3, and they all have this same issue when it is 7.4.

It happens on any execution which requires user input such as: * php bin/console make:entity * php bin/console doctrine:migrations:migrate.

Other commands like php bin/console make:migration which don't need user input work fine so it seems like the wait for input is the problem.

Running them in non-interactive mode works for the yes/no ones, but is impossible for a lot of them like make:entity

Here is the output from the terminal:

PS C:\path\project> php bin/console make:entity

 Class name of the entity to create or update (e.g. VictoriousPuppy):
 >

  Aborted.  


make:entity [-a|--api-resource] [--regenerate] [--overwrite] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<name>]

PS C:\path\project>

The abort happens instantly with no wait for input. I have both versions 7.3 and 7.4 installed and switching to 7.3 makes it work fine, so I looked at both php.ini files and can't find anything wrong. I installed them directly from the Windows download links on the php.net site https://www.php.net/downloads.php

My PHP versions are installed in C:\php\7.3 and C:\php\7.4 and to switch them I just change the PATH in the windows environment variables. php -v produces the right version if I reopen terminal.

Team member running on MacOS has no problem with 7.4 and neither does the Ubuntu 18.04 staging server, so it must be something specific to my Windows install.

like image 418
isaac_newbton Avatar asked Dec 19 '19 04:12

isaac_newbton


People also ask

Can we use PHP to write command line scripts?

There are two variables you can use while writing command line applications with PHP: $argc and $argv. The first is the number of arguments plus one (the name of the script running). The second is an array containing the arguments, starting with the script name as number zero ($argv[0]).


1 Answers

This is a bug with PHP 7.4.0 for Windows.

The bug has been registered here, and has been fixed in the 7.4.1 version, released yesterday December 18th.

Just download the latest PHP version, and you'll be fine.

like image 176
yivi Avatar answered Oct 07 '22 00:10

yivi