承接 web64/laravel-cli-colors 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

web64/laravel-cli-colors

Composer 安装命令:

composer require web64/laravel-cli-colors

包简介

Laravel package for generating CLI output with awesome colors!

README 文档

README

Laravel CLI Colors is a simple package, based on the jakub-onderka/php-console-color library, that makes it easy to output text in various colors and styles.

Laravel already comes with some built in styles for the Command class but I often output debug information in other classes and also wanted more flexibility in how to style the output, so I created this package.

Note that the colors and styling features available will depend on your OS and console settings.

Installation

composer require web64/laravel-cli-colors

To publish the colors.php config file run

php artisan vendor:publish --provider="Web64\Colors\ColorsServiceProvider" --tag="config"

Run this command to see a sample of how use can use Laravel CLI Colors.

php artisan colors:test 

Quick Start

use Web64\Colors\Facades\Colors;

Colors::red('Red Text');

Default Colors

Text Colors:

default, black, red, green, yellow, blue, magenta, cyan, light_gray, dark_gray, light_red, light_green, light_yellow, light_blue, light_magenta, light_cyan, white

Background Colors:

bg_default, bg_black, bg_red, bg_green, bg_yellow, bg_blue, bg_magenta, bg_cyan, bg_white, bg_light_gray, bg_dark_gray, bg_light_red, bg_light_green, bg_light_yellow, bg_light_blue, bg_light_magenta, bg_light_cyan

Colors::light_blue('Light blue text');
Colors::bg_light_blue('Light blue background');

Custom Styles

In the colors.php configuration file you can define your own custom styles. The key of the array will be the name of the static method on the Colors facade and the value is an array of styles to be applied.

// config.php
return [
    'myStyle' => ['bold','blue', 'bg_white'],
    ...
];
Colors::myStyle('Bold blue text with white background');

Pre-defined styles

The colors.php config file already has a list of pre-defined styles. Feel free to change, remove or add styles to this configuration file.

// Laravel-style output
Colors::info('Green text');
Colors::question('Black text on light blue background');

// Model changed styles
Colors::created("Green bg to indicate model was created");
Colors::updated("Yellow bg to indicate model was updated");
Colors::deleted("Red bg to indicate model was deleted");

View & Validate Custom Styles

Run this command to see how your custom styles look and if they are any errors.

php artisan colors:test --config

Inline Styles

To test out styles quickly you can add several styles inline and separate them with a double underscore (__).

Colors::bold__underline__reverse__blue__bg_light_gray("Text..");

When you find a style you like you, can add them to the colors.php config.

Formatting

You can format the text with bold, underline, italic and reverse.

Colors::bold()->red('Bold red text');
Colors::underline()->blue('Underlined blue text');
Colors::italic()->green('Italic green text');
Colors::reverse()->default('Reversed default text and background color');

Adding nobr() prevents a newline character from being added, so you can change styles on the same line.

Colors::nobr()->red('U');
Colors::nobr()->white('S');
Colors::blue('A');

Shortcuts

Instead of 'light_' and 'dark_' you can just prefix 'l' or 'd'.

For bold, underline and reverse, you can use shortcuts: 'b', 'u' and 'rev'

Colors::b__u__dgray__bg_lcyan('Text');
// Same as 
Colors::bold__underline__dark_gray__bg_light_cyan('Text');

Helper

A helper function is available if you don't want to use the facade.

The first argument is a string or array of styles, with the text to output as the second argument.

colors('red', 'Hello World!');
colors('b__u__red', 'Hello World!');
colors(['bold', 'underline', 'red'], 'Hello World!');

Fun Stuff

Display random colors for each character using the rainbow() function.

// Random text colors:
Colors::rainbow('Text');

// Random background colors:
Colors::reverse()->rainbow('Text');

Samples

Default Config Text Colors Background Colors

Contribute

Let me know if you have any ideas on how to improve this package!

Leave an issue here or reach out to me on Twitter @OlavHjertaker

web64/laravel-cli-colors 适用场景与选型建议

web64/laravel-cli-colors 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.45k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2019 年 02 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 web64/laravel-cli-colors 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 web64/laravel-cli-colors 我们能提供哪些服务?
定制开发 / 二次开发

基于 web64/laravel-cli-colors 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13.45k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 12
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-12