PHPackages                             exmachina/laravel-route-js - 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. exmachina/laravel-route-js

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

exmachina/laravel-route-js
==========================

Convert laravel's route to json files to be use in Javascript.

v1.1.0(5y ago)1201MITPHPPHP ^7.2

Since Jul 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/exmachina00/laravel-routes-js)[ Packagist](https://packagist.org/packages/exmachina/laravel-route-js)[ RSS](/packages/exmachina-laravel-route-js/feed)WikiDiscussions master Synced today

READMEChangelog (6)DependenciesVersions (6)Used By (0)

Laravel routes to JS
====================

[](#laravel-routes-to-js)

Convert Laravel's routes to `json` file to generate URL in Javascript

Features
--------

[](#features)

- Supports Laravel 5.8.x, 6.x, and 7.x

- Allow to specify what routes to be included/excluded.

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

[](#installation)

```
composer require exmachina/laravel-route-js
```

In your Laravel `app/config.php`, add the service provider:

```
ExMachina\LaravelRouteJs\Providers\JsRoutesServiceProvider::class
```

Configuration
-------------

[](#configuration)

First, publish the default package's configuration:

```
php artisan vendor:publish --provider="ExMachina\LaravelRouteJs\Providers\JsRoutesServiceProvider"
```

The configuration will be published to `config/route-js.php`.

ElementTypeDefaultDescription`dir`*string*resources/js/routesDirectory where the files will be saved.`route.patterns`array\[ \]Routes to be included when generating route list.
*element type: String literals or RegExp pattern or both*.
`route.exclude`*boolean*falseWhen set to **true**, exclude the routes provided in `routes.patterns`Usage
-----

[](#usage)

### Generating the routes

[](#generating-the-routes)

```
php artisan js-route:generate
```

This command will generate 2 files, the route list(`laravel-routes.json`) and the js(`laravel-routes.js`) file for the functionality. The default directory is `resources/js/routes`.

### Options

[](#options)

OptionDescription`--dir`Directory where the files will be saved`--routes`Routes to be included when generating route list.
String literals or RegExp pattern or both.

Can have multiple options for different patterns.
e.g(--routes=admin\* --routes=public.index)`--exclude`When provided, exclude the routes provided in
 `--routes` option or
`routes.patterns` in `config/route-js.php``--exclude-js`Only route list will be generate. The JS file that will act upon it will be excluded.`--append`Append the provides ROUTES to existing route list.JS Usage
--------

[](#js-usage)

```
import Route from 'path/to/laravel-route.js';
```

### Get URL using named route

[](#get-url-using-named-route)

```
Route.get('welcome');
```

### Route with parameters

[](#route-with-parameters)

Parameter names will be the same in what you provided in your Laravel routes.

```
# This will be equivalent to laravel route entry:
#  Route::get('profile/{id}').name('profile.edit')
Route.get('profile.edit', {id: 1})

# Laravel route: Route::post('profile/{id}/address/{address_id}').name('address.edit')
Route.get('address.edit', {id: 1, address_id: 1004})

# Getting route without parsing  the parameters
# route entry: {'public.user': {url: 'user/{user}', parameters: ["user"]}}
Route.getRawURL('public.user'); // result: /user/{user}

# Changing prefix and suffix of params
# getRawURL(routeName, prefix = '{', suffix = '}')
Route.getRawURL('public.user', ':', ''); // result: /user/:user
```

### Route list

[](#route-list)

You can change the route list by calling `setRoutes` method of `Route` instance

```
import Route from 'path/to/laravel-route.js';

Route.setRoutes( [ { 'route-name': 'url', parameters: []} ] )
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~6 days

Total

5

Last Release

2154d ago

Major Versions

v0.4-alpha → v1.02020-08-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7291132?v=4)[Pao Cana](/maintainers/exmachina00)[@exmachina00](https://github.com/exmachina00)

---

Top Contributors

[![exmachina00](https://avatars.githubusercontent.com/u/7291132?v=4)](https://github.com/exmachina00 "exmachina00 (23 commits)")

### Embed Badge

![Health badge](/badges/exmachina-laravel-route-js/health.svg)

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

###  Alternatives

[jasonhinkle/php-gpg

GPG / PGP port written in pure PHP with no binary dependencies

118150.3k1](/packages/jasonhinkle-php-gpg)[cocur/chain

Consistent and chainable array manipulation

8272.7k3](/packages/cocur-chain)[milo/schematron

Implementation of ISO Schematron with Schematron 1.5 back compatibility. Library does not need any XSLT.

19368.1k5](/packages/milo-schematron)

PHPackages © 2026

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