FOSJSRoutingBundle : "Route xxx does not exist"

I had the same issue and the problem was in my config file. Try checking for this:

# app/config/config.yml
fos_js_routing:
    routes_to_expose: [ myBundle_step2, myBundle_step3, ... ]

I also had this problem. Setting the options.expose parameter on the routing configuration solved it for me.

routing.yml

cart_edit:
    pattern:  /Cart/edit
    defaults: { _controller: CartCartBundle:Default:cart_edit }
    options:
        expose: true

my.js

var url = Routing.generate('cart_edit');
$.post(url, function(data) {
      //do somthing
});

Change as needed. Hope this will solve your problem.


Just for completeness: it is also possible to use annotations (options={"expose"=true}) as explained in the documentation:

// src/AppBundle/Controller/DefaultController.php

/**
 * @Route("/foo/{id}/bar", options={"expose"=true}, name="my_route_to_expose")
 */
public function indexAction($foo) {
    // ...
}

This also works for routes sets at controller level (example from one of my controllers):

/**
 * Channel controller.
 *
 * @Route("account/{account}/todos", options={"expose"=true})
 * @ParamConverter("account", class="AppBundle:Account", options={
 *     "repository_method" = "findOneById",
 *     "mapping": {"account": "id"},
 *     "map_method_signature" = true
 * })
 */
class TodoListController extends Controller
{