madnh/laravel-command-util

用于 Laravel 命令类的工具

v1.2 2017-11-26 17:00 UTC

This package is not auto-updated.

Last update: 2024-09-15 02:43:06 UTC


README

为 Laravel 命令添加实用方法。需要 Laravel/Lumen 框架 >= 5.0。

安装

要开始使用 Command Utils,只需运行

composer require madnh/laravel-command-util

基本用法

从您的命令中使用 MaDnh\LaravelCommandUtil\CommandUtil 特性

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use MaDnh\LaravelCommandUtil\CommandUtil;

class FooCommand extends Command
{
    use CommandUtil;
    
    //...
}

方法

横幅

$this->banner('message'[, $options_as_array])

Banner

$this->softBanner('message'[, $options_as_array])

Soft Banner

标题

$this->header('message'[, $options_as_array])

Header

$this->softHeader('message'[, $options_as_array])

Soft Header

标题

$this->title('message'[, $options_as_array])

Title

$this->softTitle('message'[, $options_as_array])

Soft Title

段落标题

$this->paragraphTitle('message'[, $options_as_array])

Paragraph Title

有序列表

$this->orderedList($items[, $options_as_array])

Ordered List

无序列表

$this->unorderedList($items[, $list_item_char])

Unordered List

继续使用之前的有序列表索引

$this->softTitle('Accusamus ea sit eos iusto dolore nemo.');
$index = $this->orderedList($items);

$this->softTitle('Aliquid quam ea error provident et.');
$this->orderedList($items, $index);

Continue previous ordered list

动态有序列表

$this->softTitle('Publish files');

while($file = array_shift($files)){
    $this->line($this->getListIndex().$file->getFilename());
}

Dynamic ordered lists

重置动态有序列表索引

$this->softTitle('Ut qui suscipit sequi sed.');
foreach ($items as $item) {
    $this->line($this->getListIndex().$item);
}

$this->resetOrderedList(30);

$this->softTitle('Eum beatae ea qui non aliquam.');
foreach ($items as $item) {
    $this->line($this->getListIndex().$item);
}

Reset index