LARAVEL ROUTING

All Laravel routes are define in route files , which are located in the route directory ,These file are automatically loaded by the framework.

The most basic Laravel routes accept a URI and a closure, providing a very simple and expressive method of defining routes and behavior without complicated routing configuration files:

Basic Routes

Syntax:-

Route::get(‘URI’,closer/callback);

Ex :-

Route::get(‘/about’,function()

{

return “hello world”;

});

Routes Parameter

Syntax :-

Route::get(‘uri/{parameter}’,function($para)

{

return $para;

});

Example

Route::get(‘user/{user_id}’,function($user_id)

{

return $user_id;

});

Multiple Parameter Routes

syntax :-

Route::get(‘uri/{parameter}/uri/{para}’, function($parameter, $para)

{

return $parameter $para;

});

Example:-

Route::get(‘user_name/{U_name}/user_id/{U_id}’,function($name $id)

{

return $name $id;

});

Redirect Routes

Syntax:-

Route::redirect(‘from’,’to’);

Example:-

Route::redirect(‘login’,’dashboard’);

Thanku