2017 © Pedro Peláez
 

library vivian

Php tools to provide a pretty console output

image

matks/vivian

Php tools to provide a pretty console output

  • Saturday, May 7, 2016
  • by matks
  • Repository
  • 2 Watchers
  • 9 Stars
  • 9 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Vivian

Latest Stable Version Build Status Scrutinizer Code Quality Code Coverage Latest Unstable Version License, (*1)

Tools to provide a pretty console output in ANSI/VT100 terminals, (*2)

, (*3)

Installation

Install the dependencies with composer, (*4)

composer install

Tests

Install the dev dependencies with composer, (*5)

composer install --dev

Run the unit tests suite with atoum binary., (*6)

vendor/bin/atoum -bf vendor/autoload.php -d tests/Units/

Usage

Tool

For simple styles, the class Matks\Vivian\Tools provide a useful call interface, for example:, (*7)

use Matks\Vivian\Tools as Output;

echo Output::bold('... done.') . PHP_EOL;

if ($success) {
    echo Output::green('Success');
    echo PHP_EOL;
} else {
    echo Output::red('Failure !');
    echo PHP_EOL;
    echo Output::s_list1($errors);
}

See the examples in tests/Console:, (*8)

php tests/Console/test-color
php tests/Console/test-background-color
php tests/Console/test-style
php tests/Console/test-border
php tests/Console/test-mixed
php tests/Console/test-structure
php tests/Console/test-figlet

or, (*9)

bash tests/Console/test-all.sh

Elements

For advanced displays, build the Elements you need:, (*10)

Text Element

use Matks\Vivian\Color;
use Matks\Vivian\Style;
use Matks\Vivian\Output;

$textElement = new Output\TextElement('Hello world !');

$boldStyle             = new Style\Style(Style\StyleManager::BASH_BOLD);
$greenColor            = new Color\TextColor(Color\TextColorManager::BASH_FOREGROUND_GREEN);
$cyanBackgroundColor   = new Color\BackgroundColor(Color\BackgroundColorManager::BASH_BACKGROUND_CYAN);

$textElement->setTextColor($greenColor)
            ->setBackgroundColor($cyanBackgroundColor)
            ->addStyle($boldStyle)
;

echo $textElement->render();

Bordered Element

use Matks\Vivian\Border;
use Matks\Vivian\Color;
use Matks\Vivian\Output;

$yellowColor = new Color\TextColor(Color\TextColorManager::BASH_FOREGROUND_YELLOW);
$border      = new Border\Border(Border\Border::TYPE_FRAME);

$borderedElement = new Output\BorderedElement('Hello world !', $border);
$borderedElement->setTextColor($yellowColor);

echo $borderedElement->render();

Structured Elements

use Matks\Vivian\Color;
use Matks\Vivian\Output;
use Matks\Vivian\Style;
use Matks\Vivian\Structure;

$greenColor     = new Color\TextColor(Color\TextColorManager::BASH_FOREGROUND_GREEN);
$redColor       = new Color\TextColor(Color\TextColorManager::BASH_FOREGROUND_RED);
$blinkingStyle  = new Style\Style(Style\StyleManager::BASH_BLINK);

$textElement1 = new Output\TextElement('Hello');
$textElement2 = new Output\TextElement('world');
$textElement3 = new Output\TextElement('!');
$textElement1->setTextColor($greenColor);
$textElement2->setTextColor($redColor);
$textElement3->addStyle($blinkingStyle);

$elements = array(
    $textElement1,
    $textElement2,
    $textElement3
);

$structure  = new Structure\Structure(Structure\Structure::TYPE_LIST, '#', '  ');
$structuredElements = new Output\StructuredElements($elements, $structure);
echo $structuredElements->render();

More about ANSI/VT100 terminal control

http://www.termsys.demon.co.uk/vtansi.htm, (*11)

License

Vivian is licensed under the MIT License - see the LICENSE file for details, (*12)

More advanced features

I found a far more efficient library doing the same purpose: CLImate. I recommend it., (*13)

The Versions

07/05 2016

dev-master

9999999-dev https://github.com/matks/Vivian

Php tools to provide a pretty console output

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mathieu Ferment

console

13/11 2014

v2.0

2.0.0.0 https://github.com/matks/Vivian

Php tools to provide a pretty console output

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mathieu Ferment

console

01/11 2014

v1.2

1.2.0.0 https://github.com/matks/Vivian

Php tools to provide a pretty console output

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mathieu Ferment

console

29/10 2014

v1.1

1.1.0.0 https://github.com/matks/Vivian

Php tools to provide a pretty console output

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Mathieu Ferment

console

13/10 2014

v1.0

1.0.0.0 https://github.com/matks/Vivian

Php tools to provide a pretty console output

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Mathieu Ferment

console