Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get a list of registered route paths in Laravel

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 126
    Comment on it

    If some one find a way to create an array with the registered routes paths within Laravel 4. If someone wants to get a list something like this returned:

    /
    /login
    /join
    /password
    

    Solution: For this we will use the method

    Route::getRoutes()
    

    which will return a RouteCollection. On each element, you can do a simple.

    $route->getPath()
    

    to get path of the current route.

    Each protected parameter can be get with a standard getter.

    In this Looping works like this:

    $routeCollection = Route::getRoutes();
    
    foreach ($routeCollection as $value) {
        echo $value->getPath();
    }
    

    By this way we can get a list of registered route paths in Laravel.

 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: