Download the PHP package a-bashtannik/fasti without Composer
On this page you can find all versions of the php package a-bashtannik/fasti. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download a-bashtannik/fasti
More information about a-bashtannik/fasti
Files in a-bashtannik/fasti
Package fasti
Short Description Laravel task scheduler with calendar-based management.
License MIT
Informations about the package fasti
Fasti is a Laravel package that enables developers to precisely schedule task execution in the future. With Fasti, you can defer the launch of any Job
for any period, specifying the time and date to the minute. At the designated time, Fasti retrieves the required Job from the repository and either executes it synchronously or dispatches it to a queue.
Unlike Laravel's powerful recurring task scheduler, Fasti focuses on scheduling individual tasks for specific times. It's user-friendly, allowing you to easily create, list, or cancel tasks on demand.
Installation
[!NOTE] This package requires PHP 8.2+ and Laravel 11+
Publish migration table:
⚠️ Add the tick command to your console.php
file:
Usage
Schedule your jobs using well-known Laravel patterns and interfaces.
Jobs are eligible for scheduling with Fasti if they implement a handle()
method. At the scheduled time, Fasti executes your job synchronously within the cron job process thread, alongside any other cron jobs you've defined. To leverage Laravel's queuing system, simply implement the ShouldQueue
interface on your job class. This allows Fasti to dispatch the job to Laravel's queue using the standard Bus facade behind the scenes.
This job will be executed synchronously at the specified time:
Fasti supports encrypted jobs if class implements ShouldEncrypt
interface.
Use tiny Eloquent model to store scheduled tasks
Fasti includes a lightweight Eloquent model that stores essential job information: ID, payload, and dates. While Fasti provides a service for convenient job management, you're not limited to it. In your controllers, you have the flexibility to interact directly with the Eloquent model using standard queries if you need more fine-grained control or custom operations.
Testing
Test your scheduled jobs with ease using Fasti's Fasti::fake()
method and built-in assertions.
Fasti operates as a scheduling layer for your Laravel jobs, focusing solely on when to initiate them. It's important to note that Fasti doesn't manage job execution, queues, releases, attempts, or failures.
Instead, when the scheduled time arrives, Fasti simply hands off the job to Laravel's default Bus
.
It means you are free to use well-known Bus assertion methods shipped with Laravel when the job is dispatched to the queue.
Using custom models or storage to manage scheduled jobs
For simple applications, Fasti's built-in Eloquent model is sufficient. However, if you need to store scheduled jobs in a custom database table or use a different storage mechanism, Fasti provides a way to do so.
Define your own model implementing the Bashtannik\Fasti\Contracts\SchedulableJob
interface.
It's important to note that while your model is required to implement this interface, it doesn't overload it with new properties or methods. This approach allows Eloquent to operate normally. You are simply required to provide a standard set of fields in the model or data transfer object to ensure Fasti works smoothly and your IDE's type checking is happy.
Create your own repository that implements the FastiScheduledJobsRepository
interface and bind it in your app service provider register()
method.
Hint: store human-friendly job type name
When using FastiEloquentRepository
repository, by default it stores class name in the type
field.
However, you can define your own set of human-friendly names in your AppServiceProvider like you do with morph-many relationships.
This field doesn't affect the job execution but can be useful for debugging or logging purposes.