hishamhuneidie / colored-terminal
Script to colorize text in terminal
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/hishamhuneidie/colored-terminal
Requires
- php: >=8.2
This package is auto-updated.
Last update: 2025-12-11 01:30:40 UTC
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.