FosJSRoutingBundle, route does not exist

I’m trying to generate URL in my Javascript but I can’t due to this error:

Error: The route “my_route” does not exist.

I don’t know why but the route is not recongnized…

What I did:

1) Get the bundle by composer
2) Published the assets :

php bin/console assets:install --symlink public

3) Use this in JS:

Routing.generate("my_route")

4) And then, this in my controller:

    /**
     * @Route("/route/to/route",  options = { "expose" = true }, name="my_route")
     * @param Request $request
     * @return Response
     */
    public function my_route(Request $request){ 
some things...  };

So, it’s not working…

I checked the JS dependencies that are loaded in the page:

    <script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}"></script> 
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>

The first work but the second return error 404… Why ?

Regards

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 1

Your email address will not be published. Required fields are marked *


Sp

Sp

Hi, did you solved the problem? If you did, can u explain how?
Best regards.