PHPackages                             funddy/jsrouting-bundle - 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. funddy/jsrouting-bundle

ActiveSymfony-bundle

funddy/jsrouting-bundle
=======================

JsRouting for Symfony2

51.8k↓100%1PHP

Since Jun 30Pushed 12y ago2 watchersCompare

[ Source](https://github.com/funddy/jsrouting-bundle)[ Packagist](https://packagist.org/packages/funddy/jsrouting-bundle)[ RSS](/packages/funddy-jsrouting-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

FunddyJsRoutingBundle
=====================

[](#funddyjsroutingbundle)

[![Build Status](https://camo.githubusercontent.com/89ce576ed05bbfe53f095640499742b700714d49c921db97ed8dafff91f07a52/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f66756e6464792f6a73726f7574696e672d62756e646c652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/funddy/jsrouting-bundle)

This bundle enables you to use your Symfony routes from JavaScript, allowing the generate routes in a very similar way. Inspired by [FOSJsRoutingBundle](https://github.com/FriendsOfSymfony/FOSJsRoutingBundle), it supports static and dynamic routes generation.

Setup and Configuration
-----------------------

[](#setup-and-configuration)

Add the following to your composer.json file:

```
{
    "require": {
        "funddy/jsrouting-bundle": "1.0.*"
    }
}
```

Update the vendor libraries:

```
curl -s http://getcomposer.org/installer | php
php composer.phar install

```

For finishing, register the Bundle FunddyJsRoutingBundle in app/AppKernel.php.

```
// ...
public function registerBundles()
{
    $bundles = array(
        // ...
        new Funddy\Bundle\JsRoutingBundle\FunddyJsRoutingBundle()
        // ...
    );
    // ...
}
```

Usage
-----

[](#usage)

Expose the routes that you want to have accessible from your JavaScript code adding the "expose" option to the routing entry

```
example:
    pattern: /example/{param}
    defaults: { _controller: Bundle:Controller:action }
    options:
        expose: true
```

Now it's time to decide whether you want to use static, dynamic or mixed routes.

### Dynamic Routes

[](#dynamic-routes)

This is the most flexible option. Every time you make a change in exposed routes you'll be able to access them from JavaScript. It's ideal for development environment or for those cases where you performance is not an issue. As everything in life, you have to pay a price, which is invoking an URL to regenerate all routes every time you make a request.

Include FunddyJsRoutingBundle routing

```
jsrouting:
    resource: "@FunddyJsRoutingBundle/Resources/config/routing.yml"
```

Include the scripts

```

```

### Static Routes

[](#static-routes)

Is the best solution when we talk about performance, you can include the routes with your own scripts on a single one (only one request).

Compile the routes

```
php app/console funddy:jsrouting:dump

```

Include routes in a single script

```
{% javascripts output='js/output.js'
    'js/routes.js'
    'bundles/funddyjsrouting/js/lib/jsroutingrouter.js'
%}

{% endjavascripts %}
```

### Mixed Approach

[](#mixed-approach)

So, if dynamic routes is the most flexible option and static is the one with the best performance... You can always use dynamic approach for development environment and static for production!

```
{% if app.environment != 'prod' %}

{% endif %}

{% javascripts output='js/output.js'
    'js/routes.js'
    'bundles/funddyjsrouting/js/lib/jsroutingrouter.js'
%}

{% endjavascripts %}
```

Don't worry, if the routes were already defined, the next load it will not override them.

### Have fun!

[](#have-fun)

```

    var url = Router.generate('example', {param: 'test'});

```

Defining Your Own Router
------------------------

[](#defining-your-own-router)

What if you do not want to use the default "Router" global var and define your own? Easy, include only routing runtime and define your own router.

```

    var MyOwnRouter = (function() {
        router = new FUNDDY.JsRouting.Router(
            FUNDDY.JsRouting.Routes,
            new FUNDDY.JsRouting.BagFactory(),
            new FUNDDY.JsRouting.RouteFactory()
        );

        generate = function(routeName, parameters) {
            return router.generate(routeName, parameters);
        };

        return {
            generate: generate
        };
    })();

    var route = MyOwnRouter.generate('example');

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.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/460653591c09b9cf3adfb37ef0189b0a226c5be8d59ac8fd92051538a922931e?d=identicon)[funddy](/maintainers/funddy)

---

Top Contributors

[![keyvanakbary](https://avatars.githubusercontent.com/u/717129?v=4)](https://github.com/keyvanakbary "keyvanakbary (13 commits)")[![delr3ves](https://avatars.githubusercontent.com/u/1893407?v=4)](https://github.com/delr3ves "delr3ves (1 commits)")[![javierhdez3](https://avatars.githubusercontent.com/u/1479069?v=4)](https://github.com/javierhdez3 "javierhdez3 (1 commits)")

### Embed Badge

![Health badge](/badges/funddy-jsrouting-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/funddy-jsrouting-bundle/health.svg)](https://phpackages.com/packages/funddy-jsrouting-bundle)
```

PHPackages © 2026

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