PHP code example of mxl / laravel-job

1. Go to this page and download the library: Download mxl/laravel-job 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/ */

    

mxl / laravel-job example snippets


class YourJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    __constructor($name, $birthDate)
   {
       // ...
   }

   public function handle()
   {
       // ...
   }
}

use MichaelLedin\LaravelJob\FromParameters;
use Carbon\Carbon;

class YourJob implements ShouldQueue, FromParameters
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
    __constructor(string $name, Carbon $birthDate)
    {
        // ...
    }
 
    public function handle()
    {
        // ...
    }

    public static function fromParameters(...$parameters)
    {
        return new self($parameters[0], Carbon::parse($parameters[1]));
    } 
}

use MichaelLedin\LaravelJob\Job;
use Carbon\Carbon;

class YourJob extends Job
{
    // ...
}
bash
$ php artisan queue:work
bash
$ php artisan job:dispatch YourJob
bash
$ php artisan job:dispatch '\Path\To\YourJob'
bash
$ php artisan job:dispatchNow YourJob
bash
$ php artisan job:dispatch YourJob John 1990-01-01