chege-simon/vista
Vista is a Laravel package for building clean, reusable UI views with a simple, structured approach. It helps you organize templates and components for faster development, consistent layouts, and easier maintenance across your application.
Installation:
composer require chege-simon/vista
Publish the config file (if available):
php artisan vendor:publish --provider="ChegeSimon\Vista\VistaServiceProvider"
Configuration:
config/vista.php for default settings (e.g., queue connection, job timeout).AppServiceProvider boots the package:
Vista::boot();
First Use Case:
use ChegeSimon\Vista\Jobs\ScheduleJob;
ScheduleJob::dispatch(new \App\Jobs\YourScheduledTask)
->delay(now()->addMinutes(5))
->onConnection('database');
Verify:
php artisan queue:work to process jobs.vista_jobs table in your database for job statuses.Command-to-Job Migration:
// Before (Command)
$schedule->command('your:command')->everyMinute();
// After (Job)
$schedule->call(function () {
ScheduleJob::dispatch(new YourScheduledTask);
})->everyMinute();
Dynamic Scheduling:
delay() or at() for time-based jobs:
ScheduleJob::dispatch(new YourTask)
->delay(now()->addHours(2))
->onQueue('high');
Batch Processing:
$batch = Vista::batch(['batch_id' => 'report-2023']);
$batch->dispatch(new GenerateReportJob);
$batch->dispatch(new SendReportJob);
Event Listeners:
JobProcessed, JobFailed):
Vista::listen('JobProcessed', function ($job) {
Log::info("Job {$job->id} completed");
});
vista:list artisan command to inspect pending/failed jobs.shouldRetry() in your job class.Database Dependency:
config/queue.php.Missing Horizon Features:
telescope or custom views for monitoring.queue:work or queue:listen.Job Serialization:
ShouldQueue and be serializable. Avoid non-serializable dependencies (e.g., closures, resources).Config Overrides:
config/vista.php for missing settings (e.g., max_jobs, max_timeouts).Job Stuck in "Processing" State:
finished_at column in vista_jobs to force completion.Failed Jobs Not Retrying:
shouldRetry() is implemented in your job class:
public function shouldRetry()
{
return $this->attempts() < 3;
}
Missing Jobs in Database:
QUEUE_CONNECTION=database in .env).Custom Job Tables:
vista_jobs table by binding a custom JobRepository:
Vista::extend('custom', function () {
return new CustomJobRepository();
});
Job Middleware:
handle() method:
public function handle()
{
$this->middleware(YourMiddleware::class);
// Job logic
}
Event Customization:
JobProcessed/JobFailed events to add custom payloads:
Vista::extendEvent('JobFailed', function ($job, $exception) {
return new CustomJobFailed($job, $exception, ['custom_data' => 'value']);
});
Queue Worker Hooks:
Worker class:
Vista::worker(function () {
return new CustomWorker();
});
How can I help you explore Laravel packages today?