php - laravel artisan 命令颜色不显示

标签 php laravel terminal laravel-artisan

使用 laravel artisan 命令时,我没有得到预期的颜色输出。

如果你看http://laravel.com/docs/4.2/commands , 它说“要将输出发送到控制台,您可以使用信息、评论、问题和错误方法。这些方法中的每一个都将根据其目的使用适当的 ANSI 颜色。”

但是使用终端 mintty 或 cmd,我看不到这些颜色。

例如,$this->error('Something goneError!'); 应该输出带有红色背景的文本。

缺少什么才能获得此颜色功能?

最佳答案

我知道这是一个旧答案,但这里的其他答案并不是那么高质量


问题:

正如您所发现的, native Windows 命令行不支持 ANSI 颜色。 Here you can find another SO answer with more details and useful links ,但这里有一个重要的摘录:

ANSI.SYS also works in NT-derived systems for 16-bit legacy programs executing under the NTVDM.

The Win32 console does not natively support ANSI escape sequences at all. Software such as Ansicon can however act as a wrapper around the standard Win32 console and add support for ANSI escape sequences.

解决方案(简单):

Ansicon

正如摘录中提到的,Ansicon 软件用于向 Windows 终端添加对 ANSI 颜色的支持。我没有使用过它,但它似乎为现有控制台添加了功能。

ANSICON provides ANSI escape sequences for Windows console programs. It provides much the same functionality as ANSI.SYS does for MS-DOS.

也就是说,当您想要 ANSI 颜色编码时,您似乎需要运行 ansicon 命令:

For example, to display file.ans using black on cyan as the default color:

ansicon -m30 -t file.ans

另一个解决方案(更简单):

cmder

Cmder in action

正如您所看到的,它支持 ANSI 颜色,但它还内置了许多其他简洁的功能。它也模拟一些 Unix 功能。

Cmder 是迄今为止我个人最喜欢的。

关于php - laravel artisan 命令颜色不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29422276/

相关文章:

java - Java-编译错误-找不到符号-变量终端

linux - 搜索唯一值的数量及其出现的次数

php - 如何在不刷新页面的情况下刷新下拉列表?

php - 如何使用 php 将 .xlsx 文件转换为 .xml 文件?

php - 如何在单个查询中根据 WHERE 子句有条件地选择要 SELECT 的列?

php - 将数据库中的值添加到预填写表单中

php - 试图获取非对象的属性

PHP SharePoint API 文档子目录列表

php - Laravel 特定时间后触发事件或监听器

Linux shell 脚本 : Allow user to use variables in input