Laravel 8 Auth Tutorial: Login/Register/Password Reset Example

Laravel 8 auth – login, register, logout, and reset password. In this tutorial, we will share with you on how to add authentication in Laravel 8 with login, registration, logout and password reset using Jetstream.

Laravel 8 introduce new jetstream composer command with livewire package for login, register, logout, reset password email verification, two-factor authentication, session management.

The Livewire is a library that makes it simple to build modern, reactive, dynamic interfaces using Blade, controller and validation in laravel 8.

Laravel 8 Authentication Example

  • Step 1 – Install Laravel 8 App
  • Step 2 – Database Configuration
  • Step 3 – Install Auth Scaffolding Jetstream and Livewire Package
  • Step 4 – Jetstream Configuration
  • Step 5 – Run php artisan Migrate
  • Step 6 – Install Npm Packages
  • Step 7 – Run Development Server

Step 1 – Install Laravel 8 App

In step 1, open your terminal and navigate to your local web server directory using the following command:

//for windows user
cd xampp/htdocs

//for ubuntu user
cd var/www/html

Then install laravel 8 latest application using the following command:

composer create-project --prefer-dist laravel/laravel Laravel8Auth

Step 2 – Database Configuration

In step 2, open your downloaded laravel 8 app into any text editor. Then find .env file and configure database detail like following:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db name
DB_USERNAME=db user name
DB_PASSWORD=db password

Step 3 – Install Auth Scaffolding Jetstream and Livewire Package

In step 3, install auth scaffolding jetstream package in laravel app by using the following command:

composer require laravel/jetstream

Then, use the following command to create basic login, register, logout and email verification views file:

php artisan jetstream:install livewire

OR

php artisan jetstream:install livewire --teams

Note that, if you want to create team management then you have to pass addition parameter with command.

Step 4 – Jetstream Configuration

In step 4, open fortify.php file and you can enable and disable option of jetstream package according to your requirement, which is located inside config directory.

When you open it, it looks like:

'features' => [
        Features::registration(),
        Features::resetPasswords(),
        //Features::emailVerification(),
        Features::updateProfileInformation(),
        Features::updatePasswords(),
        Features::twoFactorAuthentication(),
    ],

Step 5 – Run php artisan Migrate

In step 5, open terminal and type the following command on it to create database table:

php artisan migrate

Step 6 – Install Npm Packages

In step 6, open again command prompt and type the following command to install node js:

npm install

Then type the following command on cmd to run npm:

npm run dev

Step 7 – Run Development Server

In step 7, use the following command to start development server:

php artisan serve

Now, open browser and hit the following url on it:

http://127.0.0.1:8000/

Then you will looks like:

Laravel 8 Auth Login Page

Laravel 8 Auth Register Page

Laravel 8 Auth Dashboard Page

Leave a Comment