hishamhuneidie/colored-terminal 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

hishamhuneidie/colored-terminal

最新稳定版本:1.0.1

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.

统计信息

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

GitHub 信息

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

其他信息

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