
Beautiful PHP CLI Menus for Laravel Artisan Commands
Nuno Maduro, author of Laravel Zero and Collision (which ships with Laravel 5.6 as a dev dependency) is up to his command line dominance with a new package called nunomaduro/laravel-console-menu.
Check out how beautiful the console menu looks:
Laravel Console Menu is a wrapper for php-school/cli-menu made for Artisan commands.
Here’s a quick usage example from the project’s readme:
class 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");
}
}
Here’s how you can change the appearance of the menu with a fluent API:
$this->menu($title, $options)
->setForegroundColour('green')
->setBackgroundColour('black')
->setWidth(200)
->setPadding(10)
->setMargin(5)
->setExitButtonText("Abort")
// remove exit button with
// ->disableDefaultItems()
->setUnselectedMarker('❅')
->setSelectedMarker('✏')
->setTitleSeparator('*-')
->addLineBreak('<3', 2)
->addStaticItem('AREA 2')
->open();
Thanks to Laravel package discovery, all you have to do to start using the Laravel Artisan Commands package is install it via Composer:
composer require nunomaduro/laravel-console-menu
To learn more about the project and complete installation and documentation, check out the GitHub repository. You can also follow @enunomaduro on Twitter to see what he’s up to with Laravel Zero, Collision, and any other number of Laravel things he’s working on!
P.S. We also caught word that he will be doing a new series on YouTube (in English) soon!
Filed in: Laravel Packages / ArtisanNewsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.
Laravel Jobs

- Full Stack PHP (Mid-Level/Senior) Programmer
-
Remote
PhoneBurner - Software Developer
-
Remote, (US & Canada Only)
Patient Prism - Web Application Developer
-
Chicago Loop
Leading Real Estate Companies of the World - Multiple Laravel Developers (Part-Time)
-
Remote, USA Only
The Great Escape Room - Software Developer
-
Remote (US & Canada)
Alley
Tomorrow at Laracon Online Learn about Laravel 5.6 before it’s released
It’s hard to believe that Laracon Online is here this Wednesday, February 7th! Ticket sales are still open for…
Laravel 5.6 Dynamic Rate Limiting Provides Per-User Request Throttling
Coming in Laravel 5.6 you can use dynamic rate-limiting to determine the maximum number of requests that a user can m…