Access Laravel Routes from JavaScript

Wouldn’t it be amazing if we could access our Laravel routes from JavaScript?

Yes it would! I have been a pretty substantial app in Backbone and this would have been a nicety. Managing them yourself is not terrible but because typically in Backbone you define routes for both models and collections if you ever change a route it takes a few minutes of searching and replacing to get everything up to date.

Another useful pattern is when you have dynamic route groups. Wardrobe has this feature so end users can over-ride the admin path.

This would also make a great pairing with Jeff Way’s PHP Variables to JavaScript.