Laravel 9 Authentication Tutorial

sureshramani

Suresh Ramani

Posted on March 16, 2022

Laravel 9 Authentication Tutorial

What is Laravel?

Laravel is an open-source PHP web application framework with expressive, elegant syntax. It is an MVC framework for building simple to complex web applications using the PHP programming language.

Laravel strictly follows the MVC (Model-View-Controller) architectural pattern. It is known for its beautiful and elegant syntax as a web framework.

Key Features of Laravel

Some of the main features of Laravel are:

  • Eloquent ORM
  • Query builder
  • Reverse Routing
  • Restful Controllers
  • Migrations
  • Database Seeding
  • Unit Testing
  • Homestead
  • Source code hosted on GitHub and licensed under MIT License.
  • Most Starred PHP Framework for custom software development on Github.
  • Its ability to use all of the new features of PHP sets it apart.
  • Friendly online community
  • Detailed documentation
  • Security

New Features in Laravel 9

  • Minimum PHP Requirement
  • New Design for routes:list
  • Anonymous stub migration
  • New Query Builder Interface
  • PHP 8 String Functions

Laravel provides a very simple and cool UI package for the easy step of auth scaffolding. Laravel UI composer package provides simple authentication features like login, registration, password reset, email verification, and password confirmation using bootstrap, react, and vue.

We need an authentication system for keeping our application private. Making authentication in Laravel is quite easy. It has a built-in solution for authentication and various facility to customize it according to our requirements. If you are new in Laravel 9 then in this post I'll show you the step-by-step process for making an authentication system in Laravel 9. Let's follow the step-by-step process for making an authentication system in Laravel 9.

1. Install Laravel Project

First, open Terminal and run the following command to create a fresh laravel project:

composer create-project --prefer-dist laravel/laravel laravel9-auth
Enter fullscreen mode Exit fullscreen mode

or, if you have installed the Laravel Installer as a global composer dependency:

laravel new laravel9-auth
Enter fullscreen mode Exit fullscreen mode

2. Configure Database Details:

After, Installation Go to the project root directory, open .env file, and set database detail as follow:

DB_CONNECTION=mysql 
DB_HOST=127.0.0.1 
DB_PORT=3306 
DB_DATABASE=<DATABASE NAME>
DB_USERNAME=<DATABASE USERNAME>
DB_PASSWORD=<DATABASE PASSWORD>
Enter fullscreen mode Exit fullscreen mode

Now run the database migration command:

php artisan migrate
Enter fullscreen mode Exit fullscreen mode

3: Create Auth using scaffold

Now, in this step, we will create auth scaffold command to create a login, register, and dashboard.

composer require laravel/ui
Enter fullscreen mode Exit fullscreen mode

Generate basic scaffolding and login and registration for bootstrap

php artisan ui bootstrap
php artisan ui bootstrap --auth
Enter fullscreen mode Exit fullscreen mode

Generate basic scaffolding and login and registration for Vue

php artisan ui vue
php artisan ui vue --auth
Enter fullscreen mode Exit fullscreen mode

Generate basic scaffolding and login and registration for react

php artisan ui react
php artisan ui react --auth
Enter fullscreen mode Exit fullscreen mode

Generate basic scaffolding

php artisan ui bootstrap
php artisan ui vue
php artisan ui react
Enter fullscreen mode Exit fullscreen mode

Generate login / registration scaffolding

php artisan ui bootstrap --auth
php artisan ui vue --auth
php artisan ui react --auth
Enter fullscreen mode Exit fullscreen mode

4: Install NPM dependencies

Run this following command to install node dependency and compile CSS and js files:

npm install && npm run dev
Enter fullscreen mode Exit fullscreen mode

5. Test the authentication system

Now our Laravel 9 Authentication is ready to use. To check authentication is successfully installed or not. First Run the project.

php artisan serve
Enter fullscreen mode Exit fullscreen mode

Thank you for reading this blog.

πŸ’– πŸ’ͺ πŸ™… 🚩
sureshramani
Suresh Ramani

Posted on March 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related