You will begin by defining routes in your routes/web.php file. For example, you may access the following route by navigating to http://example.com/user in your browser:


First we need to Make Controller

php artisan make:controller UserController


define route in web.php

<?php

use App\Http\Controllers\UserController;

Route::get('/user', [UserController::class, 'index']);



Available Router Methods

The router allows you to register routes that respond to any HTTP verb:


Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);


Example

<?php

use Illuminate\Support\Facades\Route;

Route::get('/greeting', function () {
    return 'Hello World';
});



View Routes

If your route only needs to return a view, you may use the Route::view method. 

Route::view('/welcome', 'welcome');



Are you facing problems in understanding this article?
You can watch the video. Watch it now