承接 nws/terminator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nws/terminator

Composer 安装命令:

composer require nws/terminator

包简介

Composer package for working with terminal

README 文档

README

This package works only in terminals which supports ANSI ESC sequences.

Usage

This is very Simple!!!

Just create instance of NWS\Terminator\Terminator.php class

<?php
    require('../path/to/autolaod.php');
    
    $terminator = new NWS\Terminator\Terminator();
    
?>

That's all now you can use terminator's output methods

Simple output examples

Print information text.

<?php
    $terminator->info("Information Log");
?>

Print warning text.

<?php
    $terminator->warn("Warning Log");
?>

Print error text.

<?php
    $terminator->error("Error Log");
?>

Print debug text.

<?php
    $terminator->debug("Debug Log");
?>

For Advanced users

The best advantage of this package is StaticBlock OOP implementation...

Example, you want to show static text like this.

-- count    : {$fullCount}
-- done     : {$doneCount}
-- errors   : {$errorCount}

You can create this in a simple way.

<?php
    $terminator = new NWS\Terminator\Terminator();
    
    $fullCount = 100;
    $doneCount = 0;
    $errorCount = 0;
    
    $staticTexts = [
        "count" => [
            "text"  => "-- count     :   " . $fullCount,
            "style" => "info" //Optional
        ],
        "done"  => [
            "text"  => "-- done     :   " . $doneCount,
            "style" => "debug"
        ],
        "error" => [
            "text" => "-- errors    :   " . $errorCount    
        ]   
    ];
    
    $staticBlock = $terminator->createStaticBlock($staticTexts, "STATIC_BLOCK_1");
?>

The result you will see in terminal.

##########STATIC_BLOCK_1##########               
count : 100                                      
done  : 0                                        
errors: 0                                        
                                                 

To test it just run this code.

<?php
        //Create instance
        $terminator = new NWS\Terminator\Terminator();
        
        //Create variables for test
        $fullCount = 100;
        $doneCount = 0;
        $errorCount = 0;
        
        //Create texts for static block
        $staticTexts = [
            "count" => [
                "text"  => "count : " . $fullCount,
                "style" => "info" //Optional
            ],
            "done"  => [
                "text"  => "done  : " . $doneCount,
                "style" => "warn" //Optional
            ],
            "error" => [
                "text" => "errors: " . $errorCount,
                "style" => "error" //Optional
            ]
        ];
        
        //Create static block
        $staticBlock = $terminator->createStaticBlock($staticTexts, "STATIC_BLOCK_1");
        
        //Run test
        $iterator = 0;
        while ($iterator <= $fullCount) {
            $iterator++;
            usleep(100000); //To see in slow mode
            
            if ($iterator % 2 === 0) {
                $errorCount++;
                $staticBlock->updateText("error", "errors: " . $errorCount);
            } else {
                $staticBlock->updateText("done", "done  : " . $doneCount);
                $doneCount++;
            }
            
            $terminator->update();
        }
  1. Remove text from static block: $staticBlock->removeText($key)
  2. Add text to static block: $staticBlock->addText($key, $text, $style)
  3. Remove static block: $terminator->removeStaticBlock($block)

统计信息

  • 总下载量: 160
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固