16 Nov 2022

Auth Example Laravel 9

 

Step 1 – Install the Laravel 9 Project

Before creating this project, ensure you have the Laravel environment on your computer. Now open the windows terminal and run this command.

composer create-project laravel/laravel auth

Once Laravel is installed, then we will go to the next step

Step 2 – Configured Database

Use your database user name and password to the project


Step 3 – Creating Login and Registration Form

For the Authentication system, we need to know what is required to create a complete system. For this project, we need the login and registration form with some staff. In this Laravel auth project, we will use bootstrap to create a user’s login and registration form.

We need to run this command to add laravel login and registration to your project. Laravel has good optimization; you don’t have to do it manually. Laravel will do that for you. Now run this command.

composer requires laravel/ui


php artisan ui bootstrap –auth

After running this commends in our Laravel project, it will generate some controllers in your auth project directory. It will create a folder called Auth under app\Http\Controllers\Auththere you can find all stuff for your authentication system.

Here you can find

  • ConfirmPasswordController.php
  • ForgotPasswordController.php
  • LoginController.php
  • RegisterController.php
  • ResetPasswordController.php
  • VerificationController.php

Here you can modify it as per your project requested.


Also, it will make some views in your resource directory. It’s in the resources\views\auth folder.

Step 4 – Configure Bootstrap in Laravel 9

Now we will add Bootstrap 5 CDN to our project. For that, we have to go to the file resources\views\layouts\app.blade.php add these 2 lines


After that, it will look like this


Our view is ready. Now we have to go to the next step.

Step 5 – Run and Test the Project

Before we run the project, we need to migrate the database in our project. For that, we have to run this commend

php artisan migrate

Now we can run our project. For that, we have to run this commend

php artisan serve

Once the project runs, we can see the Login And Register button on our home page’s top right side.

Consolation

Finally, we created this project with laravel auth. Laravel authentication is very high. So don’t worry about the login security. Happy coding!!!


**************************

Thanks for https://linuxhint.com/laravel-9-auth-example/

No comments:

Post a Comment