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::REDTextColor::GREENTextColor::BLUETextColor::YELLOWTextColor::BLACKTextColor::PURPLETextColor::CYANTextColor::WHITE
🖌️ Background Colors
BackgroundColor::REDBackgroundColor::GREENBackgroundColor::BLUEBackgroundColor::YELLOWBackgroundColor::BLACKBackgroundColor::PURPLEBackgroundColor::CYANBackgroundColor::WHITE
🏃 Running the Script
-
Make the script executable:
chmod +x script.php
-
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
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-10