since the documentation says http://laravel.com/docs/5.1/queues , first you need to configure the driver - I would start searching for the database at the beginning:
php artisan queue:table php artisan migrate
then create the job you want to add to the queue
<?php namespace App\Jobs; use App\User; use App\Jobs\Job; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Bus\SelfHandling; use Illuminate\Contracts\Queue\ShouldQueue; class SendEmail extends Job implements SelfHandling, ShouldQueue { use InteractsWithQueue, SerializesModels; protected $user; public function __construct(User $user) { $this->user = $user; } public function handle(Mailer $mailer) { $mailer->send('emails.hello', ['user' => $this->user], function ($m) {
then in the job dispatch manager
<?php namespace App\Http\Controllers; use App\User; use Illuminate\Http\Request; use App\Jobs\SendReminderEmail; use App\Http\Controllers\Controller; class UserController extends Controller { public function sendReminderEmail(Request $request, $id) { $user = User::findOrFail($id); $sendEmailJob = new SendEmail($user);
To do this, you need to run the Queue Listener:
php artisan queue:listen
Does it answer?
source share