Add migration for jobs table and start using queues for sending emails in the background
MODIFY
.env.example
.env.example
@@ -15,7 +15,7 @@ DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
-QUEUE_DRIVER=sync
+QUEUE_DRIVER=database
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null

MODIFY
app/Http/Controllers/RegisterController.php
app/Http/Controllers/RegisterController.php
@@ -36,7 +36,7 @@ class RegisterController extends Controller {
$user->save();
- Mail::to($user->email)->send(new ConfirmRegistration($user));
+ Mail::to($user->email)->queue(new ConfirmRegistration($user));
return redirect('/register');
}

ADD
database/migrations/2018_09_12_150232_create_jobs_table.php
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateJobsTable extends Migration {
+ public function up() {
+ Schema::create('jobs', function (Blueprint $table) {
+ $table->bigIncrements('id');
+ $table->string('queue')->index();
+ $table->longText('payload');
+ $table->tinyInteger('attempts')->unsigned();
+ $table->integer('reserved_at')->unsigned()->nullable();
+ $table->integer('available_at')->unsigned();
+ $table->integer('created_at')->unsigned();
+ });
+ }
+
+ public function down() {
+ Schema::dropIfExists('jobs');
+ }
+}

Add migration for jobs table and start using queues for sending emails in the background