dklis/chalk-php

PHP library to beautify your CLI messages

1.0.6 2022-02-26 12:50 UTC

This package is auto-updated.

Last update: 2024-10-27 06:34:03 UTC


README

Chalk is a small PHP library for adding ANSI colors and other text transformations to CLI text output.

Build & Test Minimum PHP Version Latest Stable Version License

Requirements

Chalk requires PHP version 8.1 or greater.

Installation

The easiest way to get started with Chalk is through composer:

# Install as dependency
composer require "dklis/chalk-php"

Usage

<?php
use Dklis\Chalk\Chalk;

// ...

// Foreground color
$redMessage = Chalk::red('A red message');

// Background color
$redBgMessage = Chalk::redBG('A message with red background');

// Transformations
$bold = Chalk::bold('A bold message');
$underline = Chalk::underline('An underlined message');


// Multiple transformations
$multiTransform = Chalk::transform('A message', 'blue', 'redBG', 'underscore', 'bold')

Default colors

Default transformations

Adding your own

To use a custom color palette, simply create a string backed Enum implementing \Dklis\Chalk\Contracts\ColorPaletteInterface and call the Chalk::create function to create your messages.

Issues

Bug reports and feature requests can be submitted on the Github Issue Tracker.