devnotes.

Basic Routing

Routes map a URI to a piece of code — a closure or a controller method. Most routes for a typical web app live in routes/web.php.

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});

Route::get('/about', function () {
    return 'About us';
});

Route::post('/contact', [ContactController::class, 'store']);

Laravel supports all standard HTTP verbs: get, post, put, patch, delete, and options, plus Route::match(['get', 'post'], ...) and Route::any(...) for less common cases.

You can chain ->name('routeName') onto any route to give it a name usable later with the route() helper, which is far more maintainable than hardcoding URLs throughout your views and redirects:

Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
// In a Blade view: <a href="{{ route('dashboard') }}">Dashboard</a>

Run php artisan route:list anytime to see every route registered in your application, along with its HTTP method, URI, name, and controller action.

Laravel Basic Routing Tutorial | DevNotes