1. Go to this page and download the library: Download a-bashtannik/fasti library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
a-bashtannik / fasti example snippets
$job = new SendGreetingEmail($user);
Fasti::schedule($job, '2024-12-31 23:59:59'); // Schedule a job for New Year's Eve 2024
use Bashtannik\Fasti\Console\Commands\FastiTickCommand;
Schedule::command(FastiTickCommand::class)->everyMinute();
use \Bashtannik\Fasti\Facades\Fasti;
class SendGreetingEmail implements ShouldQueue
{
public function handle()
{
// Send the email
}
}
$job = new SendGreetingEmail($user);
Fasti::schedule($job, '2024-12-31 23:59:59'); // Push job to the queue for New Year's Eve 2024
use \Bashtannik\Fasti\Facades\Fasti;
class SendAlarmNotification
{
public function handle()
{
// Send the notification
}
}
$job = new SendAlarmNotification();
Fasti::schedule($job, '2025-01-01 08:00:00'); // Execute job synchronously on New Year's Day 2025
// Use the facade
use \Bashtannik\Fasti\Facades\Fasti;
Fasti::all();
Fasti::schedule($job, $at);
Fasti::scheduled($at); // List all jobs scheduled for a specific time
Fasti::cancel($job);
Fasti::cancelled(); // List all cancelled jobs
Fasti::find($id);
// Or use the Eloquent model directly
use \Bashtannik\Fasti\Models\ScheduledJob;
ScheduledJob::where('scheduled_at', '=', '2024-12-31 23:59:59')->get();
use \Bashtannik\Fasti\Facades\Fasti;
// If you are using custom model or repository, avoid using this method and test real storage instead.
Fasti::fake();
// Test if the expected job is scheduled
Fasti::assertScheduled($job);
// Or by job class name
Fasti::assertScheduled(SendGreetingEmail::class);
// Add custom assertion by using callback
Fasti::assertScheduled(function ($job) {
return $job->type === 'send_greeting_email';
});
// Many other assertions are available
Fasti::assertNotScheduled($job);
Fasti::assertScheduledAt($job, '2024-12-31 23:59:59');
Fasti::assertNotScheduledAt($job, '2024-12-31 23:59:59');
Fasti::assertCancelled($job);
Bus::assertDispatched($job);
Bus::assertNotDispatched($job);
// etc.
use Illuminate\Database\Eloquent\Model;
use Bashtannik\Fasti\Contracts\SchedulableJob;
class MyOwnModel extends Model implements SchedulableJob
{
// Your code
}
use Bashtannik\Fasti\Repositories\FastiRepository;
use App\Repositories\MyOwnRepository;
$this->app->bind(
FastiScheduledJobsRepository::class,
MyOwnRepository::class
);
// Or if you just need to switch the model
$this->app->bind(
FastiScheduledJobsRepository::class,
function () {
$repository = new FastiEloquentRepository;
$respository::$model = MyOwnModel::class;
return $repository;
}
);
use Bashtannik\Fasti\Repositories\FastiEloquentRepository;
FastiEloquentRepository::enforceTypeMapping([
'fake_job' => FakeJob::class,
]);
sh
php artisan vendor:publish --provider="Bashtannik\Fasti\Providers\FastiServiceProvider"
sh
php artisan fasti:tick --now="2024-12-31 23:59:59"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.