Setup Bootstrap auth Login and Registration in Laravel 9

Have you ever built a website or a web application that requires users to login and register to use its features? If so, you’ve probably realized how much work it can be to create your own authentication system from scratch.

Laravel already provided user authentication but it is not by default implemented on the project.

You need to manually run a few provided commands to set it up.

In this article, you will see how to implement Bootstrap auth Login and Registration in Laravel 9 applications.

Setup Bootstrap auth Login and Registration in Laravel 9


Contents

  1. Create Laravel project
  2. Database Configuration
  3. Install Laravel/UI
  4. Setup Bootstrap auth
  5. Run npm install && npm run dev
  6. Run migration
  7. Run project
  8. Output
  9. Conclusion

1. Create Laravel project

Skip this step if you have already created a Laravel project.

Using composer to create a laravel project –

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

2. Database Configuration

Open .env file to update the database connection.

Specify the host, database name, username, and password.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tutorial
DB_USERNAME=root
DB_PASSWORD=

3. Install Laravel/UI

Run the following command –

composer require laravel/ui

4. Setup Bootstrap auth

Run the following command –

php artisan ui bootstrap --auth
  • This command will generate files and update the route.
  • You can update the view, model, and migration files according to your requirement.
  • Authentication view files are stored in the resources/auth/ folder.
  • Controller files in Controllers/Auth/ folder.
  • By default generated login page has Email and password elements, and the registration page has Name, Email, Password, and Confirm Password elements.

5. Run npm install && npm run dev

Run the following command –

npm install && npm run dev

You have to keep it running.


6. Run migration

Open another terminal or command line window and run the following command –

php artisan migrate

This will create tables in the database.


7. Run project

php artisan serve

It gives the URL to run the project – http://127.0.0.1:8000


8. Output

View Output


9. Conclusion

After setting up users can register and login to your website. You do not need to write any extra code for registration and login.

If you found this tutorial helpful then don't forget to share.

Leave a Comment