PHP code example of koshkin / yii-reach-cli

1. Go to this page and download the library: Download koshkin/yii-reach-cli 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/ */

    

koshkin / yii-reach-cli example snippets


    // Message
    RCli::msg('Message text', RCli::FONT_RED)
    $this->msg('Message text', RCli::FONT_RED);

    // Message with line ending
    RCli::line('Message text', RCli::FONT_RED)
    $this->line('Message text', RCli::FONT_RED);

    // Horizontal line
    RCli::hr();
    $this->hr();
    RCli::hr('*', RCli::FONT_BLUE);

    // Header
    RCli::header('Message text');
    $this->header('Message text');
    $this->header('Message text', RCli::FONT_RED, RCli::FONT_BLUE);

    // Message with some status
    $this->status('Good news', true);
    $this->status('Bad news', false);
    $this->status('Status with some value', true, 300);


    // Ask user for question with binary answer
    $userReply = $this->confirm("Do you want to launch rocket to Mars?", RCli::FONT_YELLOW);

    // Ask user for question with custom answer
    $userReply = $this->prompt("Please enter new password", RCli::FONT_BLUE);

	// Ask user for one of predefined answers
    $answers = [ 'banana', 'apple', 'strawberry', 'stone',];
    $userReply = $this->listSelect($answers, 'Please select most tasteless thing', 'apple');


    // Include trait
	use \ReachCli\ConsoleCommandTraits\Help;

	// Optional Set default action to 'help'
	public $defaultAction = 'help';

	// Or use this everywhere you want
	echo $this->getHelp();

    $this->warning('Please try one more time');
    $this->error('Thank you Mario, but your princess is in another castle!');

    // Remember "Event 1"
    $this->inc('Event 1');
    // Remember "Event 2" for 3 times
    $this->inc('Event 2', 3);

    // Print statistic
    $this->printStat();

    $this->beginTimer(); // Start timer
    // ... Do something, maybe iteration of some cycle
    print "Execution time" . $this->stopTimer(); // Get iteration time

    print "Command total execution time" . $this->getExecutionTime();