定制 hishamhuneidie/colored-terminal 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hishamhuneidie/colored-terminal

Composer 安装命令:

composer require hishamhuneidie/colored-terminal

包简介

Script to colorize text in terminal

README 文档

README

This project allows you to easily print colored text and backgrounds in the terminal using PHP.

✨ Features

  • 🎨 Customize text color.
  • 🖌️ Customize background color.
  • 🎭 Combine text and background colors for styled terminal output.

🛠 Requirements

  • 🐘 PHP 8.0 or later.

📥 Installation

composer require --dev hishamhuneidie/colored-terminal

🚀 Usage

Here's how to use the library to print styled text in the terminal:

Example

#!/usr/bin/env php
<?php

use HishamHuneidie\ColoredTerminal\BackgroundColor;
use HishamHuneidie\ColoredTerminal\Printer;
use HishamHuneidie\ColoredTerminal\TextColor;

require __DIR__ . '/vendor/autoload.php';

// Print text with a specific color
Printer::newText('Hello world!')
       ->setColor(TextColor::BLUE)
       ->print();

// Print text with a background color
Printer::newText('Hello Mars!')
       ->setBackground(BackgroundColor::BLUE)
       ->print();

// Combine text color and background color
Printer::newText('Hello Mercury!')
       ->setColor(TextColor::RED)
       ->setBackground(BackgroundColor::YELLOW)
       ->print();

🎨 Available Colors

🖍️ Text Colors

  • TextColor::RED
  • TextColor::GREEN
  • TextColor::BLUE
  • TextColor::YELLOW
  • TextColor::BLACK
  • TextColor::PURPLE
  • TextColor::CYAN
  • TextColor::WHITE

🖌️ Background Colors

  • BackgroundColor::RED
  • BackgroundColor::GREEN
  • BackgroundColor::BLUE
  • BackgroundColor::YELLOW
  • BackgroundColor::BLACK
  • BackgroundColor::PURPLE
  • BackgroundColor::CYAN
  • BackgroundColor::WHITE

🏃 Running the Script

  1. Make the script executable:

    chmod +x script.php
  2. Run the script:

    ./script.php

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

统计信息

  • 总下载量: 95
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固