In any project routing plays an important role.In laravel 4.x we will define our routes in routes.php which is
in app/routes.php. In laravel 4.x the basic routes consist of a URL and a clousure callback.
Example: Basic Get Route
Route::get('/', function()
{
return 'Hello Findnerd';
});
Example: Basic Get Route
Route::post('foo/bar', function()
{
return 'Hello Findnerd';
});
Example: Registering a route for multiple verbs
Route::match(array('GET', 'POST'), '/', function()
{
return 'Hello Findnerd';
});
Example:Passing An Array Of Wheres
Route::get('user/{id}/{name}', function($id, $name)
{
//
})
->where(array('id' => '[0-9]+', 'name' => '[a-z]+'))
Example:Accessing A Route Parameter Value
Route::filter('old', function()
{
if (Input::get('age') < 200)
{
return Redirect::to('home');
}
});
0 Comment(s)