offworks /
wizard
一个基于symfony/console的简单向导控制台
dev-master
2017-07-02 11:18 UTC
Requires
- symfony/console: ~3.2
This package is not auto-updated.
Last update: 2024-09-18 20:45:44 UTC
README
一个基于symfony/console的简单向导控制台。
有什么新功能?
没有新功能。除了处理命令的方式有所变化。并添加了WizardCommand,该命令可以帮助您交互式地执行symfony命令。
原因
因为在某些时候,你可能不想记住你用命令做了什么。WizardCommand通过设置命令的参数和选项来利用这一点。
安装
composer require offworks/wizard
用法
设置向导
$wizard = \Offworks\Wizard\Console::createWizard(); // add your command in between. $wizard->run();
定义你的命令
扩展抽象类 Offworks\Wizard\Command
,并实现setup()和handle()方法。
<?php namespace App\Commands; use Offworks\Wizard\Command; use Offworks\Wizard\Arguments; use Offworks\Wizard\Options; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; class SendMail extends Command { public function setup() { $this->setName('mail:send'); $this->addArgument('from', InputArgument::REQUIRED, 'From email'); $this->addArgument('to', InputArgument::REQUIRED, 'to email'); $this->addOption('subject', 's', InputOption::VALUE_REQUIRED, 'email subject'); $this->addOption('message', 'm', InputOption::VALUE_OPTIONAL, 'message body'); } public function handle(Arguments $args, Options $options) { // do some mail sending. } }
然后添加该命令。
$wizard->add(new \App\Commands\SendMail); $wizard->run();