background jobs, independent of Laravel's built-in queue system
norbybaru/easypeasy-runner is a Laravel package for background jobs, independent of laravel's built-in queue system.
It currently has 0 GitHub stars and 9 downloads on Packagist (latest version v0.3.2).
Install it with composer require norbybaru/easypeasy-runner.
Discover more Laravel packages by norbybaru
or browse all Laravel packages to compare alternatives.
Last updated
A tailored custom system to execute PHP classes as background jobs, independent of Laravel's built-in queue system.
composer require norbybaru/easypeasy-runner
php artisan vendor:publish --tag="easypeasy-runner-config"
php artisan vendor:publish --tag="easypeasy-runner-migration"
Run migration
php artisan migrate
To prevent execution of unauthorized classes, you should update config/easypeasy-runner.php file
with allowed class namespace or fully qualified class name.
eg.
<?php
return [
....
'allowed_namespaces' => [
'App\\Services\\'
],
...
]
Run the following artisan command to start processing background job
php artisan background:jobs:process
<?php
use App\Services\EmailService;
use function NorbyBaru\EasyRunner\runBackgroundJob;
runBackgroundJob(
className: EmailService::class,
methodName: 'sendNotification',
params: [
'[email protected]',
'Welcome',
'This is welcome message'
]
);
PS. Ensure to set params value in correct orders as in function definition eg.
<?php
class EmailService
{
public function sendNotification(string $email, string $subject, string $message)
{
// Execute
}
}
Available options: low, medium, high
<?php
use function NorbyBaru\EasyRunner\runBackgroundJob;
runBackgroundJob(
className: EmailService::class,
methodName: 'sendUrgentNotification',
params: [
'[email protected]',
'Emergency Alert'
],
options: [
'priority' => 'high'
]
);
<?php
use function NorbyBaru\EasyRunner\runBackgroundJob;
runBackgroundJob(
className: EmailService::class,
methodName: 'sendUrgentNotification',
params: [
'[email protected]',
'Emergency Alert'
],
options: [
'priority' => 'low',
'delay' => 120
]
);
<?php
use App\Services\ReportGenerator;
use function NorbyBaru\EasyRunner\runBackgroundJob;
runBackgroundJob(
className: ReportGenerator::class,
methodName: 'generateMonthlyReport',
params: [
'2023-11'
],
options: [
'retry_attempts' => 5
]
);
New file are generated daily with date format background_jobs-YYY-MM-DD.
eg. background_jobs-2024-11-23.log.
tail -f background_jobs-2024-11-23.log
New file are generated daily with date format background_jobs_errors-YYY-MM-DD.
eg. background_jobs_errors-2024-11-23.log.
tail -f background_jobs_errors-2024-11-23.log
php artisan background:jobs:cleanup
Display Background Jobs Stats
php artisan background:jobs:stats
Live update of Background Jobs Stats
php artisan background:jobs:stats --live
Display only failed Jobs
php artisan background:jobs:stats --failed
Retry all failed jobs
php artisan background:jobs:retry-failed
Retry a single failed job
php artisan background:jobs:retry-failed --id={jobID}