Laravel Zero: A Micro-framework for console applications

Laravel Zero: A Micro-framework for console applications

Apr 13, 2019 / Ramesh Mhetre

Laravel Zero is a lightweight and modular micro-framework for developing fast and powerful console applications. Built on top of the Laravel components.

It has simple syntaxing just like laravel which enables developers to build very complex application far more quickly than other framework.

Laravel zero is built on top of the latest release of Laravel, the most popular PHP web framework. Using Laravel Zero, you are free to take advantage of Laravel's core great features, and at the same time leverage minimal application structure and a lightweight experience.

Installation is real simple like any other composer project, here is the guide.

Awesome features laravel zero supports:

  • All power of laravel including(Exception handling, Testing, Database, Logging, Filesystem)
  • Build interactive menu
  • Send desktop notifications
  • Tinker REPL
  • Self update

Build interactive menu's:

Here is how to build interactive menu's. Using the app:install Artisan command you can install the menu component:

php <your-app-name> app:install menu

Interactive menus in console applications are very powerful. They provide a simple interface that requires little interaction. With Laravel Zero, you can use the menu method to create beautiful menus:

Using menus in the console may sound silly, but is fantastic! Your users don't need to type the number corresponding to their choice any more. They can just use the arrows on their keyboard to make their selection!

Example

Create your first menu by copy pasting the code below in your commands handle  function.

$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");

When you now run your command your output should be similar to this image:

Laravel Zero interactive menu

Laravel Zero interactive menu

The appearance of the menu can be set with a fluent API. What if we like a green font on a black background? The code below shows you how to do just that and some extras.

$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();

This project is the perfect choice if you wants to build something which is mainly going to use closed user base.


Laravel Packages Laravel Laravel News

Similar Articles

PHP develop your own package with local composer environment

PHP develop your own package with local composer environment

Developing your own PHP composer package locally & integrating local file symlink within your application can speeds up development immensely.
Read more...
Convert webpage to PDF or image in laravel

Convert webpage to PDF or image in laravel

Browsershot is package to convert webpage to image or PDF in laravel.
Read more...
What is new in Laravel 5.8.4

What is new in Laravel 5.8.4

Here is what is new in Laravel v5.8.4
Read more...