Skip to content

A add color to cli text with PHP and also a ring bell if available

Notifications You must be signed in to change notification settings

leonardosahon/console-color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple Console Helper

You can color your command line with this package. This was inspired by the github gist. You should certainly use be using at least PHP 8.0 by this time.

How To Use

<?php
declare(strict_types=1);

use Console\Console;
use Console\Format\Foreground; 
use Console\Format\Style;

include_once __DIR__ DIRECTORY_SEPARATOR . "Console.php";

// Blue-colored text
Console::log("Hello console", Foreground::blue);

// White-colored text with a cyan background color
Console::log("Hello console", Foreground::white, Background::cyan);

// White colored underlined text
Console::log("Hello console", Foreground::white, style: Style::underline);

// Ding!
Console::bell(1);

Closing Note

If you're using composer, all you need is to include composer's autoload.php and remove all include_once and you're good to go.

About

A add color to cli text with PHP and also a ring bell if available

Resources

Stars

Watchers

Forks

Languages