we can define most of the routes for your application in the app/Http/routes.php
file, which is loaded by the App\Providers\RouteServiceProvider
class. The most basic Laravel routes simply accept a URI and a Closure
:
Route::get('/', function()
{
return 'Hello World';
});
Route::post('foo/bar', function()
{
return 'Hello World';
});
Route::put('foo/bar', function()
{
//
});
Route::delete('foo/bar', function()
{
//
});
Route::match(['get', 'post'], '/', function()
{
return 'Hello World';
});
Route::any('foo', function()
{
return 'Hello World';
});
Often, you will need to generate URLs to your routes, you may do so using the url
helper:
$url = url('foo');