PHP code example of gabrielmendonca / console-formatter

1. Go to this page and download the library: Download gabrielmendonca/console-formatter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gabrielmendonca / console-formatter example snippets


COLOR_BLACK = 'black';
COLOR_RED = 'red';
COLOR_GREEN = 'green';
COLOR_YELLOW = 'yellow';
COLOR_BLUE = 'blue';
COLOR_MAGENTA = 'magenta';
COLOR_CYAN = 'cyan';
COLOR_WHITE = 'white';



$cf = new ConsoleFormatter();
$cf->color(ConsoleFormatter::COLOR_RED)
  -> str("Texto em vermelho")
  -> ln()
  -> background(ConsoleFormatter::COLOR_YELLOW)
  -> str("Texto em vermelho e fundo yellow");



  GabrielMendonca\ConsoleFormatter;

  $formatter = new ConsoleFormatter();
  echo $formatter
    -> ln()
    -> str(" >>> Hello, i'm a command line helper <<<")
    -> color(ConsoleFormatter::COLOR_RED)
    -> separator()
    -> color() // reset to default color

    -> tab ()
    -> color(ConsoleFormatter::COLOR_YELLOW)
    -> str("command")
    -> color() // reset to default color
    -> str(' - this is a description for command')
    -> ln()

    -> tab ()
    -> color(ConsoleFormatter::COLOR_YELLOW)
    -> str("command")
    -> color() // reset to default color
    -> str(' - this is a description for command')
    -> ln()

    -> background(ConsoleFormatter::COLOR_YELLOW)
    -> color(ConsoleFormatter::COLOR_RED)
    -> str(" Esta lib está em desenvolvimento ") -> ln()
    -> str(" Se gostou, você pode ajudar!!! ")
    -> background() -> color()
    -> ln()
    -> ln();