We'll walk through the process of adding authentication to your Laravel application step-by-step in this article.
Laravel: What is it?
An open-source PHP web application framework with a beautiful, expressive syntax is called Laravel. It is an MVC framework for PHP web application development, ranging from basic to advanced.
The MVC (Model-View-Controller) architecture paradigm is adhered very rigidly in Laravel. It is renowned as a web framework for having exquisite and sophisticated syntax.
Important Laravel Features
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.
* The most popular PHP framework on Github for developing custom apps.
*It differs in that it can utilize all of PHP's new features.
* Friendly online community
* Detailed documentation
* Security
1. Install Laravel Project
First, open Terminal and run the following command to create a fresh laravel project:
composer create-project laravel/laravel2. 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>
Now run the database migration command:
php artisan migrate
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
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 --authGenerate basic scaffolding
php artisan ui bootstrap
php artisan ui vue
php artisan ui react4: Install NPM dependencies
Run this 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 Authentication is ready to use. To verify whether authentication has been setup successfully. First Run the project.php artisan serve