Laravel 10 Authentication Tutorial - TechvBlogs

Laravel 10 Authentication Tutorial

In this blog, we will see step by-step how to implement authentication in your Laravel 10 application.


Suresh Ramani - Author - TechvBlogs
Suresh Ramani
 

1 month ago

TechvBlogs - Google News

 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 10

  • Support for PHP 8.2
  • Native Type Declarations
  • All Validation Rules Invokable by Default
  • Column Type Native Retrieval
  • Faster Hashing Algorithm
  • whereExists() Method Support for Eloquent Builder
  • Eager Loading Optimization
  • Much More

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 to keep our application private. Authentication in Laravel is quite easy. It has a built-in solution for authentication and various facilities to customize it according to our requirements. If you are new in Laravel 10 then in this post I'll show you the step-by-step process for making an authentication system in Laravel 10. Let's follow the step-by-step process for making an authentication system in Laravel 10.

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 laravel10-auth

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

laravel new laravel10-auth

2. Configure Database Details:

After that, Installation Go to the project root directory, open the .env file, and set database details as follows:

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

Now run the database migration command:

php artisan migrate

3: Create Auth using scaffold

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

composer require laravel/ui

Generate basic scaffolding and login and registration for Bootstrap

php artisan ui bootstrap
php artisan ui bootstrap --auth

Generate basic scaffolding and login and registration for Vue

php artisan ui vue
php artisan ui vue --auth

Generate basic scaffolding and login and registration for react

php artisan ui react
php artisan ui react --auth

Generate basic scaffolding

php artisan ui bootstrap
php artisan ui vue
php artisan ui react

Generate login/registration scaffolding

php artisan ui bootstrap --auth
php artisan ui vue --auth
php artisan ui react --auth

4: Install NPM dependencies

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

npm install && npm run dev

5. Test the authentication system

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

php artisan serve

Thank you for reading this blog.

Read Also: How to use Tailwind CSS with a React App

If you want to manage your VPS / VM Server without touching the command line go and  Checkout this linkServerAvatar allows you to quickly set up WordPress or Custom PHP websites on VPS / VM in a  matter of minutes.  You can host multiple websites on a single VPS / VM, configure SSL certificates, and monitor the health of your server without ever touching the command line interface.

Comments (0)

Comment


Note: All Input Fields are required.