PHPackages                             rinvex/tmp-lord-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. rinvex/tmp-lord-laroute

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

rinvex/tmp-lord-laroute
=======================

Access Laravels URL/Route helper functions, from JavaScript.

v2.5.0(3y ago)01.8k[1 PRs](https://github.com/rinvex/tmp-lord-laroute/pulls)1MITPHPPHP ^8.1.0

Since Mar 14Pushed 2y agoCompare

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

READMEChangelog (2)Dependencies (7)Versions (32)Used By (1)

Change package name temporary to "rinvex/tmp-lord-laroute" to publish on packagist. This is temporary forked package until a new release published by author, fully supports Laravel v8+

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)

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

[](#installation)

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

###### composer.json

[](#composerjson)

```
{
	"require" : {
		"lord/laroute" : "2.*"
	}
}
```

n.b Laravel 4.x users, check out [version 1.3.2](https://github.com/aaronlord/laroute/tree/v1.3.2)

###### app/config/app.php

[](#appconfigappphp)

```
	...

	'providers' => array(
		...
		Lord\Laroute\LarouteServiceProvider::class,
	],

	...
```

### Configure (optional)

[](#configure-optional)

Copy the packages config files.

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

```

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

[](#appconfigpackageslordlarouteconfigphp)

```
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/lord/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/aaronlord/laroute/blob/master/LICENSE)

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~119 days

Recently: every ~214 days

Total

29

Last Release

1104d ago

Major Versions

v1.3.2 → v2.0.02015-02-13

PHP version history (5 changes)v1.0PHP &gt;=5.3.0

v2.0.0PHP &gt;=5.4.0

v2.4.14PHP ^7.4.0 || ^8.0.0

v2.4.15PHP ^8.0.0

v2.5.0PHP ^8.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e54af04bcacb96e00894621335f88df7ed9895b6cc245deffdc9830a21cfe29?d=identicon)[Omranic](/maintainers/Omranic)

---

Top Contributors

[![aaronlord](https://avatars.githubusercontent.com/u/1591606?v=4)](https://github.com/aaronlord "aaronlord (19 commits)")[![Omranic](https://avatars.githubusercontent.com/u/406705?v=4)](https://github.com/Omranic "Omranic (16 commits)")[![rtheunissen](https://avatars.githubusercontent.com/u/809191?v=4)](https://github.com/rtheunissen "rtheunissen (5 commits)")[![lukepolo](https://avatars.githubusercontent.com/u/2066668?v=4)](https://github.com/lukepolo "lukepolo (3 commits)")[![jipe47](https://avatars.githubusercontent.com/u/1380202?v=4)](https://github.com/jipe47 "jipe47 (3 commits)")[![martdegraaf](https://avatars.githubusercontent.com/u/9855233?v=4)](https://github.com/martdegraaf "martdegraaf (2 commits)")[![dallincoons](https://avatars.githubusercontent.com/u/6494464?v=4)](https://github.com/dallincoons "dallincoons (2 commits)")[![killtw](https://avatars.githubusercontent.com/u/1076225?v=4)](https://github.com/killtw "killtw (1 commits)")[![mputkowski](https://avatars.githubusercontent.com/u/16721200?v=4)](https://github.com/mputkowski "mputkowski (1 commits)")[![Crinsane](https://avatars.githubusercontent.com/u/1297781?v=4)](https://github.com/Crinsane "Crinsane (1 commits)")[![reecss](https://avatars.githubusercontent.com/u/2707732?v=4)](https://github.com/reecss "reecss (1 commits)")[![Anahkiasen](https://avatars.githubusercontent.com/u/1321596?v=4)](https://github.com/Anahkiasen "Anahkiasen (1 commits)")[![Schnoop](https://avatars.githubusercontent.com/u/1263407?v=4)](https://github.com/Schnoop "Schnoop (1 commits)")[![tvbeek](https://avatars.githubusercontent.com/u/2026498?v=4)](https://github.com/tvbeek "tvbeek (1 commits)")[![xeno010](https://avatars.githubusercontent.com/u/5448179?v=4)](https://github.com/xeno010 "xeno010 (1 commits)")[![dbpolito](https://avatars.githubusercontent.com/u/347400?v=4)](https://github.com/dbpolito "dbpolito (1 commits)")[![jscarmona](https://avatars.githubusercontent.com/u/7995069?v=4)](https://github.com/jscarmona "jscarmona (1 commits)")

---

Tags

laraveljavascriptroutesrouting

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rinvex-tmp-lord-laroute/health.svg)

```
[![Health](https://phpackages.com/badges/rinvex-tmp-lord-laroute/health.svg)](https://phpackages.com/packages/rinvex-tmp-lord-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)[te7a-houdini/laroute

Access Laravels URL/Route helper functions, from JavaScript.

33512.1k](/packages/te7a-houdini-laroute)

PHPackages © 2026

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