PHP code example of pointybeard / helpers-cli-message

1. Go to this page and download the library: Download pointybeard/helpers-cli-message 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/ */

    

pointybeard / helpers-cli-message example snippets




ointybeard\Helpers\Cli\Message\Message;
use pointybeard\Helpers\Cli\Colour;

(new Message("This is a message"))->display();
// This is a message

(new Message("This is a message with the date"))
    ->flags(Message::FLAG_PREPEND_DATE | MESSAGE::FLAG_APPEND_NEWLINE)
    ->display()
;
// 06:34:52 > This is a message with the date

(new Message("Message with custom date format"))
    ->dateFormat("M, d D Y~ ")
    ->flags(Message::FLAG_PREPEND_DATE | MESSAGE::FLAG_APPEND_NEWLINE)
    ->display()
;
// May, 16 Thu 2019~ Message with custom date format

(new Message("Error: This is a fancy looking error message"))
    ->foreground(Colour\Colour::FG_WHITE)
    ->background(Colour\Colour::BG_RED)
    ->flags(MESSAGE::FLAG_APPEND_NEWLINE)
    ->display()
;
// Error: This is a fancy looking error message

(new Message("All arguments in the constructor", Colour\Colour::FG_GREEN, Colour\Colour::BG_DEFAULT, Message::FLAG_APPEND_NEWLINE | Message::FLAG_PREPEND_DATE, "H:i:s > "))->display();
// 06:42:06 > All arguments in the constructor