Route::get('foo', function () {
return 'Hello World';
});
The most basic Laravel routes accept a URI and a Closure.
The Default Route Files
Route::get('/user', 'UserController@index');
All Laravel routes are defined in your route files, which are located in the routes directory.
Routes/api.php.
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);
Route::match(['get', 'post'], '/', function () {
//
});
Route::any('foo', function () {
//
});
Laravel CSRF Protection
<form method="POST" action="https://site.com/profile">
@csrf
...
</form>
Laravel makes it easy to protect your application from cross-site request forgery (CSRF) attacks.
Redirect Routes
Route::redirect('/here', '/there', 301);
View Routes
Route::view('/welcome', 'welcome');
Route::view('/welcome', 'welcome', ['name' => 'Taylor']);