Skip to main content

Introduction

This tutorial walks you through building a Laravel application with custom artisan commands using revolution/laravel-console-starter. This starter kit accelerates development of applications that primarily use artisan commands, leveraging the full Laravel framework ecosystem rather than building standalone CLI tools. Benefits of using revolution/laravel-console-starter:
  • Quick Setup — Start developing console applications immediately without complex configurations
  • Laravel Ecosystem — Use Laravel’s rich features (task scheduling, database, notifications, etc.) in your console app
  • Artisan Commands — Leverage Laravel’s powerful Artisan system to easily create and manage your own commands
  • Testability — Write tests for your console commands using Laravel’s testing framework

Prerequisites

Ensure the following software is installed before you begin.

Project Setup

1

Create a new project

Run the following command in your terminal:
This creates a my-app directory and sets up the basic console application structure.The following happen automatically during installation:
  • An .env file is generated from .env.example
  • php artisan key:generate sets the application encryption key
Main directory structure:
2

Review the environment configuration

By default, mail sending is configured to output to the log (MAIL_MAILER=log).If you need to send actual emails, configure a service like Mailgun, Postmark, or SES in your .env file.

Creating a Console Command

1

Generate a command

Use the make:command Artisan command to create a new command:
  • YourCommandName — The class name of the command (e.g., SendDailyReport)
  • your:command — The command name used to call it (e.g., report:send-daily)
This generates app/Console/Commands/YourCommandName.php.
2

Implement the command

Edit the generated file to add your logic. Here is a Hello World example:
The $signature property defines how the command is called. Write your logic in the handle() method.
3

Run the command

After execution, you can confirm the message is output to storage/logs/laravel.log and the console.

Task Scheduling with GitHub Actions

Use GitHub Actions to run commands on a regular schedule — no server cron jobs required.
1

Review the workflow file

The starter kit includes a pre-configured .github/workflows/cron.yml:
2

Change the command

Replace php artisan inspire with your own command:
To run multiple commands:
3

Adjust the schedule

Modify the cron expression to set your desired frequency:
4

Handle sensitive information with secrets

Use GitHub repository secrets for API keys, passwords, and other sensitive values.Add secrets in your repository under Settings > Secrets and variables > Actions, then reference them in the workflow:

Notification Feature

You can notify yourself of command results or errors via email, Slack, and other channels.
1

Create a notification class

This generates app/Notifications/TaskCompleted.php.
2

Configure notification channels

Publish the relevant config files if needed:
3

Send a notification from your command

For full details, refer to the Laravel Notification documentation.

Practical Application Examples

Example 1: Website Uptime Monitoring with Slack Alerts

Create a command that checks if your websites are online and sends Slack alerts when issues are detected.
1

Install the Slack notification channel

2

Create the command and notification

3

Configure Slack

Add your Slack webhook URL to .env:
Update config/services.php:
4

Implement the notification

Edit app/Notifications/WebsiteDown.php:
5

Implement the command

Edit app/Console/Commands/MonitorWebsites.php:
6

Schedule in GitHub Actions

Update .github/workflows/cron.yml:

Example 2: Cryptocurrency Portfolio Update with Discord Notifications

Fetch cryptocurrency prices from the CoinGecko API and send portfolio updates to Discord via webhook.
1

Install the Discord notification channel

2

Create the command and notification

3

Configure Discord

Add your Discord webhook URL to .env:
Update config/services.php:
4

Implement and run the command

For the full implementation, see the GitHub repository tutorial.

Example 3: Website Content Scraping with Email Notification

Create a command that scrapes content from a website and sends the results via email.
1

Create the command and notification

2

Configure mail

Update your .env with mail settings:
3

Implement and run the command

Next Steps

You now know the fundamentals of building Laravel console applications with revolution/laravel-console-starter. To continue your journey:
  • Explore Laravel’s documentation — Dive deeper into features that can enhance your console applications at laravel.com/docs
  • Implement testing — Write tests for your commands using Laravel’s testing framework to ensure reliability
  • Explore package development — Package your console commands as reusable Laravel packages if you create similar functionality across projects
  • Stay updated — Follow Laravel News and the official Laravel blog to stay current with best practices
Last modified on May 1, 2026