FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

# Basic usage The reason we choose queues is that we want to run jobs in the background. Here we will present how you can create your own job class, which you will later use in your own queue. --- - [Create a job class](#creating-a-job-class) - [Implement a job](#implement-a-job) - [Sending job to the queue](#sending-job-to-the-queue) - [Consuming the queue](#consuming-the-queue) ### Create a job class Here with help comes a generator that will allow us to quickly get started. In our example we will create the `Email` class: php spark queue:job Email The above command will create a file in `App\Jobs` namespace. Once we have our class, we need to add it to the `$jobHandlers` array, in the `Config\Queue` configuration file. ```php // app/Config/Queue.php use App\Jobs\Email; // ... /** * Your jobs handlers. */ public array $jobHandlers = [ 'email' => Email::class, ]; // ... ``` ### Implement a job One of the most popular tasks delegated to a queue is sending email messages. Therefore, in this example, we will just implement that. ```php

Back | FazBrowse Home | New Git URL