symfony / maker-bundle

Symfony Maker Bundle
https://symfony.com/
MIT License
3.35k stars 406 forks source link

Running make:entity without arguments fails #506

Open bbuehrle opened 4 years ago

bbuehrle commented 4 years ago

I created a new Symfony project using composer create-project symfony/website-skeleton which installed: - Installing symfony/maker-bundle (v1.14.3)

No other configuration or code was added to the project. When I run bin/console make:entity without any arguments, I usually am put into interactive mode where it asks for then entity name and field definitions. Now, I receive an error:

In Generator.php line 134:

  Argument 1 passed to Symfony\Bundle\MakerBundle\Generator::createClassNameDetails() must be of the type string, null given, called in <snip>\vendor\symfony\maker-bundle\src\Maker\MakeEntity.php on line 135

https://github.com/symfony/maker-bundle/blob/443411aa3c75d87efb07a67f170295ff0961e257/src/Maker/MakeEntity.php#L133-L136

https://github.com/symfony/maker-bundle/blob/443411aa3c75d87efb07a67f170295ff0961e257/src/Generator.php#L127

This may be a separate issue, but when I run make:entity with any argument then the entity is generated with an id field only and then drops out of the command.

Environment:

$ php -i
phpinfo()
PHP Version => 7.3.11

System => Windows NT BBDESKTOP 10.0 build 18363 (Windows 10) AMD64
Build Date => Oct 22 2019 11:12:32
Compiler => MSVC15 (Visual C++ 2017)
Architecture => x64
Configure Command => cscript /nologo configure.js  "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--with-pdo-oci=c:\php-snap-build\deps_aux\oracle\x64\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-snap-build\deps_aux\oracle\x64\instantclient_12_1\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--with-pgo"
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => C:\Windows
Loaded Configuration File => C:\tools\php73\php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20180731
PHP Extension => 20180731
Zend Extension => 320180731
Zend Extension Build => API320180731,NTS,VC15
PHP Extension Build => API20180731,NTS,VC15
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => disabled

Registered PHP Streams => php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar, sqlsrv
Registered Stream Socket Transports => tcp, udp, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters => convert.iconv.\*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.\*, consumed, dechunk, zlib.\*, bzip2.\*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
bbuehrle commented 4 years ago

358 Looks to be the same issue, but was closed by @balvirsingh without comment or resolution. I started a new issue since that one was almost a year old and wanted to include additional details. Let me know if you would prefer me to comment on the other issue instead.

cjhaas commented 4 years ago

I ran into this this morning as well. I've used the command dozens of times in the past on this machine however this is the first project I've started on the 5.0 line. I'm on a Windows 10 machine using Git for Window's Bash.

For me, prefixing the command with php got it to start working again, although I'm having some weird ansi escape codes showing up and --no-ansi isn't helping, but at least I can get back into interactive mode again.

php ./bin/console make:entity

weaverryan commented 4 years ago

This sounds like a possible bug. Is everyone that’s having this bun on Windows? Is anyone on a different operating system? And can you confirm that just running ./bin/console will have the error but php bin/console will not?

Thanks!

Wimble84 commented 4 years ago

Both ways php bin/console make:entity and ./bin/console make:entity give the same error as @bbuehrle.

But when I try php bin/console make:entity User to update it, it gives that

screenshot

So I cannot update the given entity ... I ran it on Debian 10 + Php7.3 + SF4.4.1

cjhaas commented 4 years ago

When I revert https://github.com/symfony/console/commit/7bcdcdfe16ed232e6197ed25c11030372b56914f#diff-81b2d36b4ec79f521cf2d553522e2a5f I'm able to use the console as I normally do. Since posix_isatty doesn't exist for Windows, there's no other call to setInteractive(false) so it just works.

If there's any other debugging I can do, or more information to add, just let me know.

bbuehrle commented 4 years ago

@weaverryan I'm on Windows 10 using Git for Windows as @cjhaas is. Prepending php to the bin/console command does allow me to use the command in interactive mode.

$ php bin/console make:entity

 Class name of the entity to create or update (e.g. BraveChef):
 > Test
T?[K?7?[30;47mest?[39;49m?8e?[K?7?[30;47mst?[39;49m?8s?[K?7?[30;47mt?[39;49m?8t?[K?7?8

 Your entity already exists! So let's add some new fields!

 ?[32mNew property name (press ?[39m?[32m<return>?[39m?[32m to stop adding fields)?[39m:
 >

 ?[37;42m          ?[39;49m
 ?[37;42m Success! ?[39;49m
 ?[37;42m          ?[39;49m

 Next: When you're ready, create a migration with ?[33mmake:migration?[39m

It certainly isn't pretty, but seems to function. Adding a field works as intended.

bbuehrle commented 4 years ago

Based on the information that @cjhaas provided:

When I revert symfony/console@7bcdcdf#diff-81b2d36b4ec79f521cf2d553522e2a5f I'm able to use the console as I normally do. Since posix_isatty doesn't exist for Windows, there's no other call to setInteractive(false) so it just works.

it seems the issue is not with symfony/maker-bundle, but with symfony/console. Should this issue be moved (or I can create a new one) to the main symfony/symfony repo?

he667 commented 4 years ago

I had the same issue under gitbash on windows 10. In the code below :

if ((!$inputStream || !stream_isatty($inputStream)) && false === getenv('SHELL_INTERACTIVE')) {

Looks like the streamisatty is always false on windows 10 on gitbash. A possible solution is to set SHELL_INTERACTIVE to whatever value you want to bypass the isatty check.

A possible fix would be to rewrite the condition and isolate the stream_isatty case.

Foomy commented 4 years ago

Some simialar here. Windows 10, Symfony 5.0 and make:controller. Also prefixing with it php does the trick.