You can install this package by composer:
composer require vdhoangson/laravel-basic-auth
Use this in routes/web.php
Route::middleware(['basic-auth'])->group(function () {
//All the routes are placed in here
Route::get('/home', 'DashboardController@dashboard');
});OR
Route::get('/home', 'DashboardController@dashboard')->middleware('basic-auth');BASIC_AUTH_USERNAME=
BASIC_AUTH_PASSWORD=
BASIC_AUTH_REALM=