Symfony Doctrine ORM CLI Font/Colors not working?

孤者浪人 提交于 2020-05-15 02:16:46

问题


I have been looking online to see how to fix this, and have been unsuccessful. I've actually had this issue for over a year now and have simply just ignored it. Now that I'm doing more doctrine ORM stuff in my Symfony 4.1 project, I would like to know if anyone knows how to fix the font/colors on my Windows 10 machine?

Command Line tools: * Powershell - Doesn't show the colors correctly * Command Prompt - Doesn't show the colors correctly * Git CMD - Doesn't show the colors correctly

This is what my CLI looks like when i'm making or editing an entity:

E:\wamp\www\GasCruiter>php bin/console make:entity



 Class name of the entity to create or update (e.g. GentleChef):
 > UserConfirmation
U[K7[30;47mser[39;49m8s[K7[30;47mer[39;49m8e[K7[30;47mr[39;49m8r[K78C[K7[30;47monfirmation[39;49m8o[K7[30;47mnfirmation[39;49m8n[K7[30;47mfirmation[39;49m8f[K7[30;47mirmation[39;49m8i[K7[30;47mrmation[39;49m8r[K7[30;47mmation[39;49m8m[K7[30;47mation[39;49m8a[K7[30;47mtion[39;49m8t[K7[30;47mion[39;49m8i[K7[30;47mon[39;49m8o[K7[30;47mn[39;49m8n[K78

 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:
 > date

 [32mField type (enter [39m[33m?[39m[32m to see all types)[39m [[33mstring[39m]:
 > datetime
d[K7[30;47matetime[39;49m8a[K7[30;47mtetime[39;49m8t[K7[30;47metime[39;49m8e[K7[30;47mtime[39;49m8t[K7[30;47mime[39;49m8i[K7[30;47mme[39;49m8m[K7[30;47me[39;49m8e[K78

 [32mCan this field be null in the database (nullable) (yes/no)[39m [[33mno[39m]:
 > no

 [32mupdated[39m: src/Entity/UserConfirmation.php

 [32mAdd another property? Enter the property name (or 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

I must be missing some sort of system font? Not exactly sure how to fix this.


回答1:


Neither the Powershell nor CMD terminals/console emulators support ANSI escape codes for colors.

This is why you're seeing these ANSI escape codes. Your terminal just doesn't know how to interpret them.

While I personally haven't used windows for a while I remember that I had good experience with ConEmu. It's brings color support amongst other nice features.

For a quick start you should give cmder a shot - it's a ready-to-go console emulator with a nice color scheme built on top of ConEmu.

Another quick option to get a console emulator with color support is to download CygWin which gives you a POSIX compatible environment on windows and use i.e. the included port of xterm.

Further any tool based on symfony/console accepts the --no-ansi flag to suppress output of ANSII escape codes.

Examples without color output:

 bin/console --no-ansi make:entity
 composer --no-ansi install


来源:https://stackoverflow.com/questions/53220153/symfony-doctrine-orm-cli-font-colors-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!