PHPackages                             te7a-houdini/laroute - 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. te7a-houdini/laroute

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

te7a-houdini/laroute
====================

Access Laravels URL/Route helper functions, from JavaScript.

2.1.1(5y ago)33512.1k↓50%5MITPHPPHP &gt;=7.1.3

Since Oct 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/amaelftah/laroute)[ Packagist](https://packagist.org/packages/te7a-houdini/laroute)[ RSS](/packages/te7a-houdini-laroute/feed)WikiDiscussions master Synced 1mo ago

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

**This package is continuous development of [aaronlord/laroute](https://github.com/aaronlord/laroute)**.

Laroute
=======

[](#laroute)

[Laravel](http://laravel.com/) has some pretty sweet [helper functions](http://laravel.com/docs/helpers#urls) for generating urls/links and its auto-json-magic makes it building APIs super easy. It's my go-to choice for building single-page js apps, but routing can quickly become a bit of a pain.

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

This package allows us to port our routes over to JavaScript, and gives us a bunch of *very familiar* helper functions to use.

[![Laroute in action](laroute.png)](laroute.png)

[![Releases](https://camo.githubusercontent.com/150b9748533b3104eefaba71b5b9b88823828c32d95c48707d36b25d36c8c2cc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f546537612d486f7564696e692f6c61726f7574652e7376673f7374796c653d666c61742d737175617265)](https://github.com/Te7a-Houdini/laroute/releases)[![Build Status](https://camo.githubusercontent.com/ed92f047ab54699fa955c6744dc912ea75422d66f6d48a7dfad7a2fad08fcf09/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f546537612d486f7564696e692f6c61726f7574652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Te7a-Houdini/laroute)[![StyleCI](https://camo.githubusercontent.com/9973e2d6cb24b4567d8b37eb45124ecca19727e3d2aade8324df5f55a207c09a/68747470733a2f2f7374796c6563692e696f2f7265706f732f3231343137303730302f736869656c64)](https://styleci.io/repos/214170700)[![Code Quality](https://camo.githubusercontent.com/ade59485df9d27c6714ae1f992106b1341965a358f1bfff3a5addf17bcc402f7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f546537612d486f7564696e692f6c61726f7574652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Te7a-Houdini/laroute/?branch=master)[![License](https://camo.githubusercontent.com/925c0fe2a3e95d1280ce447d508ed96385524067079a85527262e52d069a10c0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f546537612d486f7564696e692f6c61726f7574652e7376673f7374796c653d666c61742d737175617265)](https://github.com/Te7a-Houdini/laroute/blob/master/LICENSE)[![Downloads](https://camo.githubusercontent.com/e7de0b56a4ed05edffdf3ebfda84ee3c0d3b1cefa970ead8f466532a480ed258/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f546537612d486f7564696e692f6c61726f7574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/te7a-houdini/laroute)

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

[](#installation)

Install the usual [composer](https://getcomposer.org/) way.

```
composer require te7a-houdini/laroute
```

### Configure (optional)

[](#configure-optional)

Copy the packages config files.

```
php artisan vendor:publish --provider='Te7aHoudini\Laroute\LarouteServiceProvider'

```

###### app/config/packages/Te7aHoudini/laroute/config.php

[](#appconfigpackageste7ahoudinilarouteconfigphp)

```
return [

    /*
     * The destination path for the javascript file.
     */
    'path' => 'public/js',

    /*
     * The destination filename for the javascript file.
     */
    'filename' => 'laroute',

    /*
     * The namespace for the helper functions. By default this will bind them to
     * `window.laroute`.
     */
    'namespace' => 'laroute',

    /*
     * Generate absolute URLs
     *
     * Set the Application URL in config/app.php
     */
    'absolute' => false,

    /*
     * The Filter Methode
     *
     * 'all' => All routes except "'laroute' => false"
     * 'only' => Only "'laroute' => true" routes
     * 'force' => All routes, ignored "laroute" route parameter
     */
    'filter' => 'all',

    /*
     * Action Namespace
     *
     * Set here your controller namespace (see RouteServiceProvider -> $namespace) for cleaner action calls
     * e.g. 'App\Http\Controllers'
     */
    'action_namespace' => '',

    /*
     * The path to the template `laroute.js` file. This is the file that contains
     * the ported helper Laravel url/route functions and the route data to go
     * with them.
     */
    'template' => 'vendor/te7a-houdini/laroute/src/templates/laroute.js',

    /*
     * Appends a prefix to URLs. By default the prefix is an empty string.
    *
    */
    'prefix' => '',

];

```

### Generate the `laroute.js`

[](#generate-the-laroutejs)

To access the routes, we need to "port" them over to a JavaScript file:

```
php artisan laroute:generate

```

With the default configuration, this will create a `public/js/laroute.js` file to include in your page, or build.

```

```

**Note: You'll have to `laroute:generate` if you change your routes.**

JavaScript Documentation
------------------------

[](#javascript-documentation)

By default, all of the functions are under the `laroute` namespace. This documentation will stick with this convention.

### action

[](#action)

Generate a URL for a given controller action.

```
/**
 * laroute.action(action, [parameters = {}])
 *
 * action     : The action to route to.
 * parameters : Optional. key:value object literal of route parameters.
 */

laroute.action('HomeController@getIndex');
```

### route

[](#route)

Generate a URL for a given named route.

```
/**
 * laroute.route(name, [parameters = {}])
 *
 * name       : The name of the route to route to.
 * parameters : Optional. key:value object literal of route parameters.
 */

 laroute.route('Hello.{planet}', { planet : 'world' });
```

### url

[](#url)

Generate a fully qualified URL to the given path.

```
/**
 * laroute.url(name, [parameters = []])
 *
 * name       : The name of the route to route to.
 * parameters : Optional. value array of route parameters.
 */

 laroute.url('foo/bar', ['aaa', 'bbb']); // -> /foo/bar/aaa/bbb
```

### link\_to

[](#link_to)

Generate a html link to the given url.

```
/**
 * laroute.link_to(url, [title = url, attributes = {}]])
 *
 * url        : A relative url.
 * title      : Optional. The anchor text to display
 * attributes : Optional. key:value object literal of additional html attributes.
 */

 laroute.link_to('foo/bar', 'Foo Bar', { style : "color:#bada55;" });
```

### link\_to\_route

[](#link_to_route)

Generate a html link to the given route.

```
/**
 * laroute.link_to_route(name, [title = url, parameters = {}], attributes = {}]]])
 *
 * name       : The name of the route to route to.
 * title      : Optional. The anchor text to display
 * parameters : Optional. key:value object literal of route parameters.
 * attributes : Optional. key:value object literal of additional html attributes.
 */

 laroute.link_to_route('home', 'Home');
```

### link\_to\_action

[](#link_to_action)

Generate a html link to the given action.

```
/**
 * laroute.link_to_action(action, [title = url, parameters = {}], attributes = {}]]])
 *
 * action     : The action to route to.
 * title      : Optional. The anchor text to display
 * parameters : Optional. key:value object literal of route parameters.
 * attributes : Optional. key:value object literal of additional html attributes.
 */

 laroute.link_to_action('HelloController@planet', undefined, { planet : 'world' });
```

PHP Documentation
-----------------

[](#php-documentation)

### Ignore/Filter Routes

[](#ignorefilter-routes)

By default, all routes are available to laroute after a `php artisan laroute:generate`. However, it is sometimes desirable to have laroute ignore certain routes. You can do this by passing a `laroute` route option.

```
Route::get('/ignore-me', [
    'laroute' => false,
    'as'      => 'ignoreme',
    'uses'    => 'IgnoreController@me'
]);

Route::group(['laroute' => false], function () {
    Route::get('/groups-are-super-useful', 'GroupsController@index');
});
```

Licence
-------

[](#licence)

[View the licence in this repo.](https://github.com/Te7aHoudini/laroute/blob/master/LICENSE)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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 ~80 days

Total

5

Last Release

2082d ago

Major Versions

1.0.1 → 2.0.02020-03-25

PHP version history (2 changes)1.0.0PHP &gt;=7.0

2.0.0PHP &gt;=7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef00b962479d759ffb75fb1f9e8dc02211d0bed49cb26bac0c650b81da0a1001?d=identicon)[Te7a-Houdini](/maintainers/Te7a-Houdini)

---

Top Contributors

[![amaelftah](https://avatars.githubusercontent.com/u/17250137?v=4)](https://github.com/amaelftah "amaelftah (15 commits)")[![JieAnthony](https://avatars.githubusercontent.com/u/38497992?v=4)](https://github.com/JieAnthony "JieAnthony (1 commits)")

---

Tags

javascriptlaravelroutesroutinglaraveljavascriptroutesrouting

### Embed Badge

![Health badge](/badges/te7a-houdini-laroute/health.svg)

```
[![Health](https://phpackages.com/badges/te7a-houdini-laroute/health.svg)](https://phpackages.com/packages/te7a-houdini-laroute)
```

###  Alternatives

[lord/laroute

Access Laravels URL/Route helper functions, from JavaScript.

8022.0M8](/packages/lord-laroute)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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