Download the PHP package laravelba/laravel-js-routes without Composer
On this page you can find all versions of the php package laravelba/laravel-js-routes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravelba/laravel-js-routes
More information about laravelba/laravel-js-routes
Files in laravelba/laravel-js-routes
Package laravel-js-routes
Short Description Access Laravel routes from your javascript files.
License MIT
Informations about the package laravel-js-routes
Laravel Javascript Routes
DEPRECATED
This package is no longer maintained. Please use https://github.com/aaronlord/laroute or any other alternative you may find!
Why?
We love the Laravel routing system and we often use named routes like route('users.show', ['id' => 1])
to generate http://domain.tld/users/1
.
With the amazing uprising of Javascript frameworks (AngularJS, EmberJS, Backbone, etc.) it's hard to track changes on your routes between the backend and the REST calls from your Javascript.
The goal of this library is to expose those named routes to your frontend so you can do: Router.route('users.show', {id: 1})
and get the same result.
Installation
Begin by installing this package through Composer.
To use this package, add its service provider to your config/app.php
providers array.
Usage
The ServiceProvider will add a new command routes:javascript
to your artisan
commands.
By default, this command will generate a routes.js
file on your resources/assets/js
folder. This contains all named routes in your app.
That's it! You're all set to go.
Lazy Tip If you use elixir (or any js task manager), set up a watcher that runs this command whenever your php routes change.
Arguments
Name | Default | Description |
---|---|---|
name | routes.js | Output filename |
Options
Name | Default | Description |
---|---|---|
path | resources/assets/js | Where to save the generated filename, relative to the base path. (ie. "public/assets" folder if you don't plan to mix it.) |
middleware | null | If you want only some routes to be available on JS, you can use a middleware (like js-routable) to select only those |
object | Router | If you want to choose your own global JS object (to avoid collision) |
prefix | null | If you want to a path to prefix to all your routes |
Javascript usage
By default, the command will generate a routes.js
file on your resources/assets/js
folder, so you can use elixir:
You may generate the routes file in your public folder instead...
...then include it in your views:
In any case, you'll have a Routes
object on your global scope.
Examples:
Contributing
This project uses phpunit
for php testing and jasmine
for JS testing.
Check available grunt tasks in the Gruntfile.js
file.
Found a bug?
Please, let us know! Send a pull request (better) or create an issue. Questions? Ask! We will respond to all issues.
Inspiration
Although no code was copied, this package is greatly inspired by FOSJsRoutingBundle for Symfony.
License
This package is open-sourced software licensed under the MIT license
All versions of laravel-js-routes with dependencies
illuminate/support Version ^5.0
illuminate/console Version ^5.0
illuminate/filesystem Version ^5.0
illuminate/routing Version ^5.0