There are 8 simple steps for laravel 8 authentication:

  1. Create a laravel 8 project
  2. “Laravel UI” package installation
  3. “Auth scaffolding” Generation
  4. “NPM” dependencies installation
  5. Setup the database
  6. Changings in a file
  7. Migration
  8. Test the project

1- Create a laravel 8 project

First, we've to create a laravel project. To create a new project open the ‘git bash’ in the ‘htdocs ’ folder, make sure the folder path ‘C:\xampp\htdocs’ in git bash. Now type the following command in git bash to create a new project:

composer create-project laravel/laravel=8.0 auth

If you do not want to mention the laravel version then simply remove the “=8.0”, in this case, the composer will automatically install the latest version of laravel. ‘auth’ is the project name.


2- “Laravel UI” package installation

Once the project is created, Now change the folder address by typing:

cd auth

or open the git bash by right-clicking inside the folder ‘auth’ and then execute the following command to install the laravel UI package:

composer require laravel/ui

3- “Auth scaffolding” Generation

After successfully installation of laravel UI package now execute the following command to scaffold the auth with vue, bootstrap or react, etc.

php artisan ui vue — auth

php artisan ui bootstrap --auth

4- “NPM” dependencies installation

In the final step, execute the following command to make frontend more attractive and beautiful:

npm install && npm run dev

If you found the error ‘bash: npm: command not found’

Then download and install the node.js pre-build install: https://nodejs.org/en/download/

and again execute this command.

5- Setup the database

Run the localhost and open the phpmyadmin and create a new database

Now open the project folder in an editor and open the .env file and change the ‘DB_DATABASE’ name to your database name:

6- Changings in a file

Open the AppServiceProvider.php file in ‘app/providers/AppServiceProvider.php’:

Add ‘use Illuminate\Support\Facades\Schema;’ outside of the class and type ‘Schema::defaultStringLength(191);’ in the boot function.

7- Migration

Now save all the files and type the following command in the git bash and press enter:

php artisan migrate

8- Test the project

Laravel authentication is successfully created. Now run the project on a localhost server ‘http://localhost/auth/public/’:

Click on the ‘Register’ button for registration and add you details and click register:

And you're logged in: