PHPackages                             rafal/javascriptroutingserviceprovider - 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. rafal/javascriptroutingserviceprovider

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

rafal/javascriptroutingserviceprovider
======================================

JavascriptRouting Service Provider provides easy way to access your routes inside Javacript files. It's cool because putting your routes inside js files as static strings sucks.

0261PHP

Since Jul 3Pushed 12y ago1 watchersCompare

[ Source](https://github.com/Efk3/JavascriptRoutingServiceProvider)[ Packagist](https://packagist.org/packages/rafal/javascriptroutingserviceprovider)[ RSS](/packages/rafal-javascriptroutingserviceprovider/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

JavascriptRouting Service Provider
==================================

[](#javascriptrouting-service-provider)

JavascriptRouting Service Provider provides easy way to access your routes inside Javacript files. It's cool because putting your routes inside js files as static strings sucks.

Installation (composer)
-----------------------

[](#installation-composer)

```
require: "rafal/javascriptroutingserviceprovider": "1.0.*@dev"

```

Options
-------

[](#options)

- `jsrouting.path` - Required. Path where `router.js` ( name by default ) will be created.
- `jsrouting.file_name` - Output file name. Default `router.js`.
- `jsrouting.refresh` - If true routes will be generated on each request. Default `true`.
- `jsrouting.basepath` - If true request basepath will be inserted before each generated route. Default `false`.
- `jsrouting.skip` - Add one (single string) or multiple (array) regular expression to skip routings.

Example
-------

[](#example)

Lets say you have:

```
$app->register(new Rafal\JavascriptRoutingServiceProvider\JavascriptRoutingServiceProvider(), array(
    'jsrouting.path'        => __DIR__.'/public/js',
    'jsrouting.file_name'   => 'router.js',
    'jsrouting.refresh'     => $app['debug'],
    'jsrouting.basepath'    => true,
    `jsrouting.skip'		=> array("/^\/_profiler/"),
));

$app->get('/{name}/extensions/are/{what}', function() use($app) {
    // your cool code
})->bind('opinion')->value('name', 'Rafals')->assert('what', '(cool|lame)');

```

Now you have to remeber to include `router.js` file in your layout.

From now you can use `Router` class inside your JavaScript files. For example:

```
Router::get('opinion', {name:'Johns', what:'lame'}) # => /project/web/Johns/extensions/are/lame
Router::get('opinion', {what:'cool'}) # => /project/web/Rafals/extensions/are/cool
Router::get('opinion', {what:'cool'}, false) # => /Rafals/extensions/are/cool
Router::get('opinion', {what:'bazinga'}) # ERROR !

```

As you can se Router class will respect all requirements, and default values defined for your routes. You can overwrite the default request basepath inserting option by the third parameter.

License
-------

[](#license)

JavascriptRouting Service Provider is licensed under the MIT license.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0caac613cb178cb957654219fbd9632739ed7fcc9f2bd26d8f4c3d2e01dd6aff?d=identicon)[Efk3](/maintainers/Efk3)

---

Top Contributors

[![RafalFilipek](https://avatars.githubusercontent.com/u/80960?v=4)](https://github.com/RafalFilipek "RafalFilipek (4 commits)")[![Efk3](https://avatars.githubusercontent.com/u/2657358?v=4)](https://github.com/Efk3 "Efk3 (2 commits)")

### Embed Badge

![Health badge](/badges/rafal-javascriptroutingserviceprovider/health.svg)

```
[![Health](https://phpackages.com/badges/rafal-javascriptroutingserviceprovider/health.svg)](https://phpackages.com/packages/rafal-javascriptroutingserviceprovider)
```

###  Alternatives

[letudiant/composer-shared-package-plugin

This composer plugin allows you to share selected packages between your projects with symlinks.

16450.9k1](/packages/letudiant-composer-shared-package-plugin)[tpoxa/shortcodes

Wordpress style shorttags support for Yii2

2313.5k](/packages/tpoxa-shortcodes)

PHPackages © 2026

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