Managing scheduled tasks in Laravel typically involves interacting with the command line via php artisan schedule:list. However, for a more visual and interactive experience, a new package called Scheduler List offers a web-based dashboard.
Developed by Akshay, this package transforms your scheduled tasks into a user-friendly interface, allowing you to view, manage, and even trigger them directly from your browser.
A Comprehensive Task Overview
The Scheduler List dashboard provides a clear view of all registered tasks within your Laravel application. It displays crucial information for each task, including:
- Schedule: The cron expression defining when the task should run.
- Next Run Time: The calculated time for the task's next execution.
- Timezone: The timezone associated with the task's schedule.
- Constraints: Any specific conditions or limitations attached to the task.
Furthermore, any description() calls made on your tasks will be reflected in the UI, making it easier to understand the purpose of each scheduled job. The tasks are intelligently grouped by type – Artisan commands, closures, and shell jobs – and the dashboard supports filtering and searching across command names, expressions, and descriptions.
Schedule::command('inspire')
->everyMinute()
->description('Displays a random motivational quote.');
On-Demand Task Execution
A key feature of Scheduler List is its ability to run tasks on demand. When manual execution is enabled, you can initiate a task directly from the dashboard. This functionality opens a console overlay that streams the command's terminal output in real-time. The amount of output displayed is configurable, with a default limit of 12,000 characters, preventing excessive data from overwhelming the interface.
Security and Configuration
By default, the Scheduler List dashboard is disabled and protected by the web and auth middleware. Both the dashboard's availability and the manual execution feature are opt-in, controlled via environment variables:
SCHEDULER_LIST_ENABLED=true
SCHEDULER_LIST_MANUAL_EXECUTION=false
For production environments, it is highly recommended to implement custom authorization logic. The package's README suggests defining a gate to restrict access to authorized users, such as administrators:
Gate::define('viewSchedulerList', function ($user) {
return $user->is_admin;
});
Running arbitrary commands from a browser poses a security risk. Therefore, manual_execution should remain disabled in production unless robust access controls are in place.
Installation
To integrate Scheduler List into your Laravel project, use Composer:
composer require devakshay/scheduler-list-laravel
php artisan vendor:publish --tag="scheduler-list-laravel-config"
Once installed and enabled, the dashboard will be accessible at the /schedulers route. You can find more details and the source code on GitHub. A live demo is also available at scheduler.devakshay.app.
Key Takeaways:
- Provides a web-based dashboard for Laravel scheduled tasks.
- Displays task details like cron expressions, next run times, and descriptions.
- Enables on-demand task execution with real-time output streaming.
- Features opt-in enabling and manual execution, with security considerations for production.
Source: https://laravel-news.com/scheduler-list-a-web-dashboard-for-laravels-scheduled-tasks