I
I
Igor2016-11-25 13:13:43
Laravel
Igor, 2016-11-25 13:13:43

How to pass list of routes from server to client?

The situation is as follows - I am writing a site on laravel and react + redux. I really hate to duplicate things on both sides and so the question arose - is there a normal way to pass a list of routes for a page being loaded? I understand that for compound paths you need some library that will replace parameters by mask, so the question should rather sound like this - do you use any libraries to figure out routes from the server to the client? This may not necessarily be laravel, but, say, rails or Django. Or do frontenders duplicate all paths?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
newpy, 2016-11-25
@newpy

$routeCollection = Route::getRoutes();

foreach ($routeCollection as $value) {
    echo $value->getPath();
}

Route::getByName()
Route::getByAction()

See Laravel API class Route and RouteCollection, methods are available via facades

I
Ivan Kondratiev, 2016-11-29
@inik23

https://github.com/aaronlord/laroute

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question