Commands

1.x version
Maintained

Commands

fos:js-routing:dump

This command dumps the route information into a file so that instead of having the controller generated JavaScript, you can use a normal file. This also allows to combine the routes with the other JavaScript files in assetic.

1
$ php app/console fos:js-routing:dump

Instead of the line

1
<script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>

you now include this as

1
<script src="/js/fos_js_routes.js"></script>

Or inside assetic, do

1
2
3
4
5
6
{% javascripts filter='?yui_js'
    'bundles/fosjsrouting/js/router.js'
    'js/fos_js_routes.js'
%}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}

Caution

You should follow the Symfony documentation about generating URLs in the console: Configuring The Request Context Globally.

Tip

If you are using JMSI18nRoutingBundle, you need to run the command with the --locale parameter once for each locale you use and adjust your include paths accordingly.

fos:js-routing:debug

This command lists all exposed routes:

1
$ php app/console fos:js-routing:debug [name]

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.