Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Routing in Laravel 4.x

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 208
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: