Let’s Build a console app with Laravel Zero
Hey folks, today I will like to show you an pratical example of how to build an console application with Laravel Zero.
For those how don’t know, Laravel Zero is unofficial and customized version of Laravel optimised for building console/shell/command-line applications.
The core of Laravel Zero is a micro-framework that comes with only 3 Laravel PHP Components:
illuminate/config
illuminate/console
illuminate/container
For more information, you can take a look on the github project: https://github.com/laravel-zero/laravel-zero.
On this article we are bulding a very simple application without showing the full pontencial and features of Laravel Zero.
Now, let’s make a Weather application, in order show the weather information of the current day.
Create a Laravel Zero application
composer create-project --prefer-dist laravel-zero/laravel-zero applicationAfter the installation, go inside the application folder an run:
php applicationBy default, your application will show an fancy message on your terminal plus an notification on your Operating System.
We need an HTTP client, in order to consume an Weather API, so let’s include the Adam Wathan Zttp.
composer require kitetail/zttpZttp is a developer-experience focused HTTP client, optimized for most common use cases. Allowing consuming an API super easily.
Build your command
Let’s go app/DefaultCommand.php and apply the following modifications:

Source code: https://github.com/nunomaduro/laravel-zero-weather
Finally, since your application is a weather application, let’s rename the executable:
php application rename weatherAnd thats it! Your application is now ready to be used!
php weather
Finally, like I said, this is a really simple example (not well coded). On next articles, I may talk about other features of Laravel Zero, for example:
- Support of Laravel 5 Service Providers
- Ships with a standalone compiler
