PHPackages                             fedeisas/laravel-js-routes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fedeisas/laravel-js-routes

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fedeisas/laravel-js-routes
==========================

Laravel 4 routes from Javascript

1.6(11y ago)63138.1k↓35.7%12[2 issues](https://github.com/fedeisas/laravel-4-js-routes/issues)MITJavaScriptPHP &gt;=5.4.0

Since Feb 6Pushed 10y ago4 watchersCompare

[ Source](https://github.com/fedeisas/laravel-4-js-routes)[ Packagist](https://packagist.org/packages/fedeisas/laravel-js-routes)[ RSS](/packages/fedeisas-laravel-js-routes/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (11)Versions (6)Used By (0)

Laravel Javascript Routes
=========================

[](#laravel-javascript-routes)

[![Travis Badge](https://camo.githubusercontent.com/4c31dc00573656963d9213fb5bdf1684ea32c591f9161333bf36e5c666912a3f/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f66656465697361732f6c61726176656c2d342d6a732d726f757465732e706e67)](http://travis-ci.org/fedeisas/laravel-4-js-routes)[![Latest Stable Version](https://camo.githubusercontent.com/2957d99af43bc744c63016161d67a138e13225d74fb2f5d72dbee1a6477efeff/68747470733a2f2f706f7365722e707567782e6f72672f66656465697361732f6c61726176656c2d342d6a732d726f757465732f762f737461626c652e706e67)](https://packagist.org/packages/fedeisas/laravel-4-js-routes)[![Latest Unstable Version](https://camo.githubusercontent.com/5f7cdc79ae4eb61dd3192082ed516e63d479af870bebd7d06f7de23d38bc7df3/68747470733a2f2f706f7365722e707567782e6f72672f66656465697361732f6c61726176656c2d342d6a732d726f757465732f762f756e737461626c652e706e67)](https://packagist.org/packages/fedeisas/laravel-4-js-routes)[![Total Downloads](https://camo.githubusercontent.com/c5931e2369d95ec1670139325ef588739a82d7021085c2114da645fb75ae2def/68747470733a2f2f706f7365722e707567782e6f72672f66656465697361732f6c61726176656c2d342d6a732d726f757465732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/fedeisas/laravel-4-js-routes)[![License](https://camo.githubusercontent.com/ef4b5a59d6186ef8bdc604d572b84319e2e43fe6e101b4620e4b4a52dd7d0de0/68747470733a2f2f706f7365722e707567782e6f72672f66656465697361732f6c61726176656c2d342d6a732d726f757465732f6c6963656e73652e706e67)](https://packagist.org/packages/fedeisas/laravel-4-js-routes)

Why?
----

[](#why)

I love the Laravel 4 routing system and I often use named routes like `route('users.show', array('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.

Laravel 5
---------

[](#laravel-5)

I haven't had the time to update this package to Laravel 5. Eventually, I'll create a new repo for that.

Requirements
------------

[](#requirements)

- Laravel **4.1**

Installation
------------

[](#installation)

Begin by installing this package through Composer. Edit your project's `composer.json` file to require `fedeisas/laravel-4-js-routes`.

```
{
  "require": {
        "laravel/framework": "4.0.*",
        "fedeisas/laravel-4-js-routes": "1.*"
    },
    "minimum-stability" : "dev"
}
```

Next, update Composer from the Terminal:

```
$ composer update
```

Once this operation completes, the final step is to add the service provider. Open `app/config/app.php`, and add a new item to the providers array.

```
'Fedeisas\LaravelJsRoutes\LaravelJsRoutesServiceProvider',
```

Usage
-----

[](#usage)

By default the command will generate a `routes.js` file on your project root. This contains all **named** routes in your app. That's it! You're all set to go. Run the `artisan` command from the Terminal to see the new `routes:javascript` commands.

```
$ php artisan routes:javascript
```

> **Lazy Tip** If you use Grunt, you could set up a watcher that runs this command whenever your routes files change.

Arguments
---------

[](#arguments)

NameDefaultDescription**name***routes.js*Output filenameOptions
-------

[](#options)

NameDefaultDescription**path***base\_path()*Where to save the generated filename. (ie. public assets folder)**filter***null*If you want only some routes to be available on JS, you can use a filter (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 routesJavascript usage
----------------

[](#javascript-usage)

You have to include the generated file in your views (or your assets build process).

```

```

And then you have a `Routes` object on your global scope. You can use it as:

```
Router.route(route_name, params)
```

Example:

```
Router.route('users.show', {id: 1}) // returns http://dommain.tld/users/1
```

If you assign parameters that are not present on the URI, they will get appended as a query string:

```
Router.route('users.show', {id: 1, name: 'John', order: 'asc'}) // returns http://dommain.tld/users/1?name=John&order=asc
```

Contributing
------------

[](#contributing)

```
$ composer install --dev
$ ./vendor/bin/phpunit
```

```
$ npm install -g grunt-cli
$ npm install
$ grunt travis --verbose
```

In addition to a full test suite, there is Travis integration.

Found a bug?
------------

[](#found-a-bug)

Please, let me know! Send a pull request or a patch. Questions? Ask! I will respond to all filed issues.

Inspiration
-----------

[](#inspiration)

Although no code was copied, this package is greatly inspired by [FOSJsRoutingBundle](https://github.com/FriendsOfSymfony/FOSJsRoutingBundle) for Symfony.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 93.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~63 days

Total

5

Last Release

4277d ago

PHP version history (2 changes)1.0PHP &gt;=5.3.0

1.6PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d1a4ac79561ed7edef104265d9cabcdbc936a701456d6c65d28ac29255f3bbf?d=identicon)[fedeisas](/maintainers/fedeisas)

---

Top Contributors

[![fedeisas](https://avatars.githubusercontent.com/u/251675?v=4)](https://github.com/fedeisas "fedeisas (57 commits)")[![zaalbarxx](https://avatars.githubusercontent.com/u/3301242?v=4)](https://github.com/zaalbarxx "zaalbarxx (3 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

---

Tags

laravelartisanroutinggenerators

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/fedeisas-laravel-js-routes/health.svg)

```
[![Health](https://phpackages.com/badges/fedeisas-laravel-js-routes/health.svg)](https://phpackages.com/packages/fedeisas-laravel-js-routes)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M200](/packages/laravel-ai)[laravel/folio

Page based routing for Laravel.

603583.7k33](/packages/laravel-folio)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[laravel/surveyor

Static analysis tool for Laravel applications.

86121.4k13](/packages/laravel-surveyor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
