Skip to content

Instantly share code, notes, and snippets.

@moradi-morteza
Last active April 11, 2020 06:55
Show Gist options
  • Save moradi-morteza/cd2cabeff0809c020ded8440b69dc69e to your computer and use it in GitHub Desktop.
Save moradi-morteza/cd2cabeff0809c020ded8440b69dc69e to your computer and use it in GitHub Desktop.
[job] #LaravelT
<?php
---in file config queue you should change QUEUE_CONNECTION------> in env QUEUE_CONNECTION=database -------> reset config env in command
php artisan queue:table // create a migration for jobs
php artisan make:job SendVerificationEmailJob
// where you want to do :
SendVerificationEmailJob.dispatch($user);
// in send verificationEmailJob class
private $user;
public function __construct (User $user){
$this->user=$user;
}
public function handle(){
// get user data and do your work
send email ....
}
// to start jobs in artisan :
php artisan queue:work
// if you close command with ctrl+C then queue stoped!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment