PHPackages                             macellan/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. macellan/laravel-js-routes

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

macellan/laravel-js-routes
==========================

Laravel routes from Javascript

2.3(1y ago)324.5k↓41.3%2MITPHPPHP &gt;=7.2.0

Since Feb 6Pushed 1y agoCompare

[ Source](https://github.com/macellan/laravel-js-routes)[ Packagist](https://packagist.org/packages/macellan/laravel-js-routes)[ RSS](/packages/macellan-laravel-js-routes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (7)Versions (11)Used By (0)

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

[](#laravel-javascript-routes)

Why
---

[](#why)

I love the Laravel 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.

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

[](#installation)

You can install this package via composer:

```
composer require macellan/laravel-js-routes
```

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)**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

42

—

FairBetter than 90% of packages

Maintenance47

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 82.6% 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 ~454 days

Recently: every ~468 days

Total

10

Last Release

396d ago

Major Versions

1.6 → 2.02020-03-02

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

1.6PHP &gt;=5.4.0

2.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fea6ab8454f28af0ac4265b6f7dcbb97c4881dd978aaabd9fa49be0767db4b24?d=identicon)[aytekin](/maintainers/aytekin)

![](https://www.gravatar.com/avatar/1f4b3832b769a6cbd136895170c0befd945d09ea66a182c80313444360221673?d=identicon)[burakcalik](/maintainers/burakcalik)

---

Top Contributors

[![fedeisas](https://avatars.githubusercontent.com/u/251675?v=4)](https://github.com/fedeisas "fedeisas (57 commits)")[![faytekin](https://avatars.githubusercontent.com/u/4013224?v=4)](https://github.com/faytekin "faytekin (7 commits)")[![zaalbarxx](https://avatars.githubusercontent.com/u/3301242?v=4)](https://github.com/zaalbarxx "zaalbarxx (3 commits)")[![bcalik](https://avatars.githubusercontent.com/u/9222368?v=4)](https://github.com/bcalik "bcalik (1 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

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[lord/laroute

Access Laravels URL/Route helper functions, from JavaScript.

8022.0M8](/packages/lord-laroute)[laravel/folio

Page based routing for Laravel.

608453.9k27](/packages/laravel-folio)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[fedeisas/laravel-js-routes

Laravel 4 routes from Javascript

63133.4k](/packages/fedeisas-laravel-js-routes)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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