定制 kielabokkie/laravel-fancy-console 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

kielabokkie/laravel-fancy-console

Composer 安装命令:

composer require kielabokkie/laravel-fancy-console

包简介

A trait to give your console commands some extra fancy output

README 文档

README

Author Packagist Version Software License

Fancy Console for Laravel provides a FancyConsole trait that gives you a few extra fancy styled console outputs to compliment the already useful default Laravel ones.

Requirements

  • PHP >= 7.2
  • Laravel 5.8 and up

Installation

Install the package via composer:

composer require kielabokkie/laravel-fancy-console

Usage

Firstly you'll have to add the FancyConsole trait to your command:

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Kielabokkie\FancyConsole\Traits\FancyConsole;

class MyCommand extends Command
{
    use FancyConsole;
}

Success and fail messages

To make it easier to style success and fail messages you will have access to the following methods:

$this->success('Yes, it worked!');
$this->success('Yes, it worked!', 'OK');

$this->fail('Oh no, it did not work.');
$this->fail('Oh no, it did not work.', 'BUMMER');

$this->successBlock('This is a great success');

$this->errorBlock('This is a serious error');

Which gives you the following output:

screenshot

Loading indicator

Laravel already comes with an easy progress bar but if you want to show progress in a different way you can use the dot loading indicator:

for ($i = 0; $i < 100; $i++) {
    $this->dot();
}

The code above will output 100 dots on the same line. If you want to restrict the number of dots on a line you can set the dot width:

$this->setDotWidth(40);

for ($i = 0; $i < 100; $i++) {
    $this->dot();
}

Now it will jump to the next line once the number of dots reach a multiple of 40.

If you know the total number of loading dots your command will be outputting you can set the total dots and the output will show you the current progress and total per line.

$dotTotal = 100;

$this->setDotTotal($dotTotal);
$this->setDotWidth(40);

for ($i = 0; $i < $dotTotal; $i++) {
    $this->dot();
}

Lastly, if you would like to use a different character instead of a dot, you can pass it as a parameter:

$this->dot('-');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固