Installation:
composer require a-bashtannik/fasti
php artisan vendor:publish --provider="Bashtannik\Fasti\FastiServiceProvider"
php artisan migrate
config/fasti.php) and creates a scheduled_jobs table.First Use Case: Schedule a job for a specific datetime:
use Bashtannik\Fasti\Facades\Fasti;
use App\Jobs\SendWelcomeEmail;
$job = new SendWelcomeEmail($userId);
Fasti::schedule($job, now()->addHours(1)); // Runs in 1 hour
Run the Scheduler:
Add to your app/Console/Kernel.php:
protected function schedule(Schedule $schedule)
{
$schedule->command('fasti:run')->everyMinute();
}
Scheduling Jobs:
Fasti::schedule(new ProcessOrder($order), now()->addMinutes(5));
Fasti::schedule(new NotifyUser($user), now()->addDay(), ['priority' => 'high']);
Listing/Canceling Jobs:
// List pending jobs
$pendingJobs = Fasti::pending()->get();
// Cancel a job by ID
Fasti::cancel($jobId);
Queue vs. Sync Execution:
Fasti::schedule($job, $datetime, [], true); // 4th param = $sync
Recurring Tasks (via Laravel Scheduler):
fasti:run command in Schedule facade for periodic checks:
$schedule->command('fasti:run')->everyFiveMinutes();
Job Serialization:
ShouldQueue or is serializable.serialize() or Laravel’s dispatchSync() for sync jobs.Timezones:
config/fasti.php (defaults to app timezone).Carbon instances or DateTime objects for consistency.Error Handling:
.env).handleFailure() (override Bashtannik\Fasti\Jobs\ScheduledJob).Testing:
Fasti facade or use Fasti::fake() (if supported) for unit tests.travel() in PHPUnit:
$this->travelTo($scheduledTime)->runQueuedJobs();
Time Precision:
now()->addSeconds(1)) or use unique timestamps.Queue Workers:
php artisan queue:work is running (or use supervisor/foreman).Database Locks:
DB_CONNECTION timeout in .env.Timezone Mismatches:
config/fasti.php or pass Carbon-aware datetimes.Check Pending Jobs:
php artisan fasti:list
Log Execution:
config/fasti.php:
'debug' => env('FASTI_DEBUG', false),
storage/logs/laravel.log.Manual Trigger:
php artisan fasti:run --force
Custom Job Repository:
Bashtannik\Fasti\Repositories\JobRepository to add fields (e.g., user_id).php artisan vendor:publish --tag=fasti-migrations
Event Listeners:
ScheduledJobCreated):
use Bashtannik\Fasti\Events\ScheduledJobCreated;
ScheduledJobCreated::listen(function ($job) {
Log::info("Job {$job->id} scheduled for {$job->runs_at}");
});
API Endpoints:
Route::get('/scheduled-jobs', [FastiController::class, 'index']);
Fasti::pending()/Fasti::cancel() in controllers.Custom Commands:
FastiCommand to add subcommands (e.g., fasti:reschedule).How can I help you explore Laravel packages today?