In this tutorial you will learn about the Laravel 7/6 Login Registration Logout Example and its application with practical example.
In this Laravel 7/6 login, registration, logout example tutorial I will show you how to use laravel default login registration logout in laravel application. In this tutorial you will learn to create your own laravel login, registration, forget password and reset password functionality. This tutorial is complete laravel authentication system guide that helps you to implement laravel default authentication in laravel application.
Laravel 7/6 Login Registration Logout Example
- First Install Laravel Fresh Project
- Configuration changes in .env file
- Generate Laravel Application Key
- Database Migration
- Create a Login Authentication Laravel
- Run the Development Server
1. First Install Laravel Fresh Project
First of all we need to create a fresh laravel project, download and install Laravel using the below command
1 |
composer create-project --prefer-dist laravel/laravel blog |
2. Configuration changes in .env file
Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.
1 2 3 4 5 6 |
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=here your database name here DB_USERNAME=here database username here DB_PASSWORD=here database password here |
3. Generate Laravel Application Key
Now we will generate laravel application key using following command:
1 |
php artisan key:generate |
4. Database Migration
Before you run php artisan migrate command. Go to the app/providers/AppServiceProvider.php and put the following code in boot method
1 2 3 4 5 6 7 |
Use Schema; public function boot() { Schema::defaultStringLength(191); } |
1 |
php artisan migrate |
5. Laravel Authentication
Now, we will enable laravel default authentication using following command:
1 |
composer require laravel/ui |
The above command will generate default authentication routes, controllers and views files for Laravel Login Authentication and registration. After that you can run following command and check ui commands info.
1 |
php artisan ui --help |
You can use following commands for creating auth:
Using Vue:
1 |
php artisan ui vue --auth |
Using React:
1 |
php artisan ui react --auth |
Now you need to run following npm command, otherwise you will not see layout of login and register page.
Install NPM:
1 2 3 |
npm install npm run dev |
6. Run the Development Server
1 2 3 4 5 |
php artisan serve If you want to run the project diffrent port so use this command php artisan serve --port=8080 |
laravel authentication is successfully completed, Now Go to the browser and hit the
1 |
URL : http://localhost:8000/login |
If you did not run PHP artisan server command, direct go to your browser and type the URL
1 |
URL : http://localhost/blog/public/ |