FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 261 forks source link

FOSJsRoutingBundle not generate routes in Symfony 5.x #390

Closed SHTIKOV closed 4 years ago

SHTIKOV commented 4 years ago
Description

I have problem in Symfony 5.0.8 with generate routes, when I run this command (bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json) my json file generated with empty routes array.

File fos_js_routes.json
{"base_url":"","routes":[],"prefix":"","host":"localhost","port":"","scheme":"http","locale":[]}
Trouble in this code

https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/blob/7dfd2165c1170a73e5929e70fb80ef57f5539869/Extractor/ExposedRoutesExtractor.php#L90

https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/blob/7dfd2165c1170a73e5929e70fb80ef57f5539869/Extractor/ExposedRoutesExtractor.php#L98

What can I do to solve this problem?

SHTIKOV commented 4 years ago

I added option for my route and this route has been added to json, but how can I generate js routes without this option?

/**
 * @Route("/login", name="login", options={"expose"=true})
 */
stof commented 4 years ago

Exposing a route can be done either from the route definition or from the config of the bundle: https://symfony.com/doc/master/bundles/FOSJsRoutingBundle/usage.html#generating-uris

But if the route is not exposed to the JS generator, you won't be able to generate a URL for it. That's the whole point.

SHTIKOV commented 4 years ago

@stof, thank you :)