PHP code example of norbybaru / easypeasy-runner

1. Go to this page and download the library: Download norbybaru/easypeasy-runner 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/ */

    

norbybaru / easypeasy-runner example snippets


composer 



return [
    ....
    'allowed_namespaces' => [
        'App\\Services\\'
    ],
    ...
]



use App\Services\EmailService;
use function NorbyBaru\EasyRunner\runBackgroundJob;

runBackgroundJob(
    className: EmailService::class, 
    methodName: 'sendNotification',
    params: [
        '[email protected]', 
        'Welcome',
        'This is welcome message'
    ]
);



class EmailService
{
    public function sendNotification(string $email, string $subject, string $message)
    {
        // Execute
    }
}



use function NorbyBaru\EasyRunner\runBackgroundJob;

runBackgroundJob(
    className: EmailService::class,
    methodName: 'sendUrgentNotification',
    params: [
        '[email protected]',
        'Emergency Alert'
    ],
    options: [
        'priority' => 'high'
    ]
);



use function NorbyBaru\EasyRunner\runBackgroundJob;

runBackgroundJob(
    className: EmailService::class,
    methodName: 'sendUrgentNotification',
    params: [
        '[email protected]',
        'Emergency Alert'
    ],
    options: [
        'priority' => 'low',
        'delay' => 120
    ]
);



use App\Services\ReportGenerator;
use function NorbyBaru\EasyRunner\runBackgroundJob;

runBackgroundJob(
    className: ReportGenerator::class, 
    methodName: 'generateMonthlyReport', 
    params: [
        '2023-11'
    ], 
    options: [
        'retry_attempts' => 5
    ]
);
bash
php artisan vendor:publish --tag="easypeasy-runner-config"
bash
php artisan vendor:publish --tag="easypeasy-runner-migration"
bash
php artisan migrate
bash
php artisan background:jobs:process
bash
php artisan background:jobs:cleanup
bash
php artisan background:jobs:stats
bash
php artisan background:jobs:stats --live
bash
php artisan background:jobs:stats --failed
bash
php artisan background:jobs:retry-failed
bash
php artisan background:jobs:retry-failed --id={jobID}