在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):nunomaduro/laravel-console-menu开源软件地址(OpenSource Url):https://github.com/nunomaduro/laravel-console-menu开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):About Laravel Console MenuLaravel Console Menu was created by, and is maintained by Nuno Maduro, and is a php-school/cli-menu wrapper for Laravel Console Commands. Installation
Require Laravel Console Menu using Composer: composer require nunomaduro/laravel-console-menu UsageQuick Setupclass MenuCommand extends Command
{
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$option = $this->menu('Pizza menu', [
'Freshly baked muffins',
'Freshly baked croissants',
'Turnovers, crumb cake, cinnamon buns, scones',
])->open();
$this->info("You have chosen the option number #$option");
}
} Setup with a questionclass MenuCommand extends Command
{
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$option = $this->menu('Pizza menu')
->addOption('mozzarella', 'Mozzarella')
->addOption('chicken_parm', 'Chicken Parm')
->addOption('sausage', 'Sausage')
->addQuestion('Make your own', 'Describe your pizza...')
->addOption('burger', 'Prefer burgers')
->setWidth(80)
->open();
$this->info("You have chosen the text option: $option");
}
} Setup with advanced option, in this case, a passwordclass MenuCommand extends Command
{
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$menu = $this->menu('Pizza menu')
->addOption('mozzarella', 'Mozzarella')
->addOption('chicken_parm', 'Chicken Parm')
->addOption('sausage', 'Sausage')
->addQuestion('Make your own', 'Describe your pizza...');
$itemCallable = function (CliMenu $cliMenu) use ($menu) {
$cliMenu->askPassword()
->setValidator(function ($password) {
return $password === 'secret';
})
->setPromptText('Secret password?')
->ask();
$menu->setResult('Free spice!');
$cliMenu->close();
};
$menu->addItem('Add extra spice for free (password needed)', $itemCallable);
$option = $menu->addOption('burger', 'Prefer burgers')
->setWidth(80)
->open();
$this->info("You have chosen the text option: $option");
}
} AppearanceAvailable colors: $this->menu($title, $options)
->setForegroundColour('green')
->setBackgroundColour('black')
->setWidth(200)
->setPadding(10)
->setMargin(5)
->setExitButtonText("Abort") // remove exit button with ->disableDefaultItems()
->setTitleSeparator('*-')
->addLineBreak('<3', 2)
->addStaticItem('AREA 2')
->open(); Check out the full documentation here. ContributingThank you for considering to contribute to Laravel Console Menu. All the contribution guidelines are mentioned here. You can have a look at the CHANGELOG for constant updates & detailed information about the changes. You can also follow the twitter account for latest announcements or just come say hi!: @enunomaduro Support the developmentDo you like this project? Support it by donating LicenseLaravel Console Menu is an open-sourced software licensed under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论