Laravel for Beginners – Learn to Build Full-Stack Web Apps

Loading video...

Basic Routing

The default routes file is located in routes/web.php.

The default routes for console commands is located in routes/console.php.

Available request methods

Laravel 11 supports the following request methods when defining route

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

Route that matches multiple request methods

Route::match(['get', 'post'], '/', function () {
    // ...
});

Route that matches all request methods

Route::any('/', function () {
    // ...
});

Redirect routes

Route::redirect('/home', '/');
Route::redirect('/home', '/', 301);
// the same as
Route::permanentRedirect('/home', '/');

View Routes

Route::view('/contact', 'contact');
 
Route::view('/contact', 'contact', ['phone' => '+995557123456']);

Discussion

Sign in to join the discussion.

No comments yet. Be the first to start the discussion!