DEV Community

Talha Maqsood
Talha Maqsood

Posted on

Simple Authentication in Laravel 8.9.0 step-by-step with images

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 have 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.

Alt Text
Alt Text

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

Alt Text

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

Alt Text

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'

Alt Text

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

Alt Text

5- Setup the database
Run the localhost and open the phpmyadmin and create a new database

Alt Text

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

Alt Text

6- Only 1 line change in 'AppServiceProvider.php' 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.

Alt Text

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

php artisan migrate

Alt Text

8- Test the project
Laravel authentication is successfully created. Now run the project on a localhost server 'http://localhost/auth/public/':

Alt Text

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

Alt Text

And you are logged in:

Alt Text

You can also see, edit, or delete the registered users in phpmyadmin:

Alt Text

--I hope it helps!

Top comments (0)