shomisha/laravel-console-wizard
最新稳定版本:1.12.0
Composer 安装命令:
composer require shomisha/laravel-console-wizard
包简介
This package offers a framework for creating interactive console wizards within your Laravel applications.
README 文档
README
This package provides a basis for creating multi-step wizards with complex input inside the console. It is best used for customising generator command output, but can be used for handling any sort of tasks.
<?php namespace App\Console\Commands; use Shomisha\LaravelConsoleWizard\Command\Wizard; use Shomisha\LaravelConsoleWizard\Steps\ChoiceStep; use Shomisha\LaravelConsoleWizard\Steps\TextStep; class IntroductionWizard extends Wizard { protected $signature = "wizard:introduction"; protected $description = 'Introduction wizard.'; public function getSteps(): array { return [ 'name' => new TextStep("What's your name?"), 'age' => new TextStep("How old are you?"), 'gender' => new ChoiceStep("Your gender?", ["Male", "Female"]), ]; } public function completed() { $this->line(sprintf( "This is %s and %s is %s years old.", $this->answers->get('name'), ($this->answers->get('gender') === 'Male') ? 'he' : 'she', $this->answers->get('age') )); } }
The example above shows a simple example of how you can create a wizard with several input prompts and then perform actions using the answers provided by the user.
Running php artisan wizard:introduction in your console would execute the above wizard and produce the following output:
shomisha:laravel-console-wizard shomisha$ php artisan wizard:introduction
What's your name?:
> Misa
How old are you?:
> 25
Your gender?:
[0] Male
[1] Female
> 0
This is Misa and he is 25 years old.
Take a look at our wiki pages for more instructions and other Wizard features.
统计信息
- 总下载量: 7.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 133
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-04