Implementing Authentication in Laravel 8/9 using Bootstrap UI

Implementing authentication in Laravel is very easy and simple. Almost everything is already configured for use. The authentication file is located at config/auth.php. This file contains various well documented options for customizing the functionality of the authentication services.

In this tutorial, we will show you how to build a Laravel application from scratch and implement built-in authentication for user registration and login with a beautiful modern UI powered by Bootstrap.

Follow the steps below to complete this tutorial:

  1. Create a Laravel project using Composer. If you do not have Composer installed already, you can learn how to install it here. Use the composer create-project --prefer-dist laravel/laravel command, followed by your project name, to create a Laravel application:
  2. composer create-project --prefer-dist laravel/laravel sample-app
  3. Navigate to the newly created project:
  4. cd sample-app
  5. Next, install laravel/ui using Composer:
  6. composer require laravel/ui
  7. Set up the built-in authentication using Bootstrap UI using the following command:
  8. php artisan ui bootstrap --auth
  9. Install dependencies:
  10. npm install
  11. Update MySQL Database connection settings in the .env file as shown in the example below:
  12. DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=your-databae-name
    DB_USERNAME=your-username
    DB_PASSWORD=your-your-password
  13. To migrate user authentication tables into the database using the following command:
  14. php artisan migrate
  15. To view quick changes on your UI, use the following command on a separate terminal from inside your project root folder:
  16. npm run watch
  17. Next, run the following command to start your application from inside your project root folder:
  18. php artisan serve --port 8000
  19. Now, open http://localhost:8000 in your browser. You should see a page like the following:
  20. You can now modify the login and registration page as per your need.