PHP code example of irfantoor / terminal

1. Go to this page and download the library: Download irfantoor/terminal 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/ */

    

irfantoor / terminal example snippets




rfanTOOR\Terminal;

$t = new Terminal;

# printing with style
$t->write("Hello ", "green");
$t->writeln("World ", "red");

# use writeMultiple to write multiple lines.
$t->writeMultiple(
    [
        'These are multiple lines',
        'with a common style applied',
        'to all lines'
    ], 
    'bg_blue, white'
);

# reading from console
$response = $t->read("Are you ok? [Y/N] ", "info");

$t->write("you responded with: ");
$t->writeln($response, "info, reverse");


 
ew IrfanTOOR\Terminal();
$t->setTheme(
    [
        'info' => 'bg_black, yellow',
        'url'  => 'red, underline',
    ]
);

# Theme
$t->writeln("Modified theme >> info", "info");
$t->writeln("https://github.com/irfantoor/console", "url");

$t->setTheme(
    [
        'url' => 'red, bg_light_yellow, underline'
    ]
);

$t->writeln("https://github.com/irfantoor/console", "url");