2017 © Pedro Peláez
 

library crayon

A simple functional PHP library for formatting string output

image

troublete/crayon

A simple functional PHP library for formatting string output

  • Wednesday, February 21, 2018
  • by troublete
  • Repository
  • 1 Watchers
  • 2 Stars
  • 129 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Crayon

A simple functional PHP library for formatting string output 🌈, (*1)

Build Status Reliability, (*2)

Preview

preview, (*3)

Install

$ composer require troublete/crayon

Introduction

The purpose of the library is to simplify the usage of formatting of strings on the PHP CLI. The usage should be strictly a functional one, to write the least code with the biggest impact. Simple use the function Crayon\text which returns a Crayon\Font instance which handles the formatting and return as string. Formatting calls may be chained., (*4)

⚠️ Be aware that there is a formatting order: underline > italic > bold > color. Last color set will be used and that italic weighs more than bold formatting. So if both options are set the prior one will be used., (*5)

Usage

<?php
require_once 'path/to/vendor/autoload.php';

use function Crayon\{text as crayon, error, success};

echo crayon('text')->green(); // returns green text
echo crayon('text')->green()->bold(); // returns bold green text
echo crayon('text')->green()->underline()->bold(); // returns underlined bold green text
echo crayon('text')->green()->underline()->bold()->background(); // returns underlined bold green backgrounded text

echo success('text'); // returns green bold text with checkmark at the end
echo error('text'); // returns red bold text with x at the end

API

Crayon\Font

->bold() – sets text bold

->italic() – sets text italic

->underline() – sets text underlined

->red() – sets text color to red

->green() – sets text color to green

->yellow() – sets text color to yellow

->blue() – sets text color to blue

->magenta() – sets text color to magenta

->cyan() – sets text color to cyan

->background() – turns coloring from fore to background coloring

License

GPL-2.0 © Willi Eßer, (*6)

The Versions

21/02 2018

dev-master

9999999-dev

A simple functional PHP library for formatting string output

  Sources   Download

GPL-2.0

The Requires

  • php >=7.0

 

The Development Requires

by Willi Eßer

21/02 2018

1.2.0

1.2.0.0

A simple functional PHP library for formatting string output

  Sources   Download

GPL-2.0

The Requires

  • php >=7.0

 

The Development Requires

by Willi Eßer

16/09 2017

1.1.0

1.1.0.0

A simple functional PHP library for formatting string output

  Sources   Download

GPL-2.0

The Requires

  • php >=7.0

 

The Development Requires

by Willi Eßer

16/09 2017

1.0.0

1.0.0.0

A simple functional PHP library for formatting string output

  Sources   Download

GPL-2.0

The Requires

  • php >=7.0

 

The Development Requires

by Willi Eßer