FriendsOfSymfony / FOSJsRoutingBundle

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

Symfony4 issues publishing assets #345

Closed etshy closed 5 years ago

etshy commented 5 years ago

I followed the docs here But I have the following error when trying to publish the assets Unrecognized option "resource" under "fos_js_routing". Available options are "cache_control", "request_context_base_url", "router", "routes_to_expose", "serializer".

I'm not sure the "publish the assets" is supposed to do but it doesn't work at all because the config at the previous step is not existing.

Edit: Also there is nothing for symfony 4 in the docs, all the paths are web instead of public etc. Is this bundle usable with symfony 4 ?

tobias-93 commented 5 years ago

Hi @etshy, thank you for using this bundle! We do have Symfony 4 compatibility, but it is somewhat limited. There's a recipe for Symfony Flex here: https://github.com/symfony/recipes-contrib/tree/master/friendsofsymfony/jsrouting-bundle/2.0, which should install the bundle (you don't need to do the steps in our installation documentation). In our usage documentation, you can find how to use this bundle with Webpack Encore (for SF4).

etshy commented 5 years ago

Hi.

Thanks for your help but I still have questions. Is it possible to expose all my routes ?

In my config/routes/annotations.yaml config file I have the following

controllers:
    resource: ../../src/Controller/
    type: annotation

When i installed (re-installed) this bundle, I had this config file config/routes/fos_js_routing.yaml

fos_js_routing:
    resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"

As the both config files are about routing and both config key have a resource option, I thought I could have my whole routes by changing that

fos_js_routing:
    resource: ../../../src/Controller/

It seems a bit inconsistent with the Symfony routing config.

It seems the routes_to_expose option key isn't exist too


In YamlFileLoader.php line 253:

  The routing file "***\config\routes/fos_js_routing.yaml" contains unsupported keys for "fos_js_routing": "routes_to_expose". Expected one of: "resource", "type", "prefix", "path", "host", "schemes", "methods", "defaults", "requirements", "options", "condition", "controller", "name_prefix", "trailing_slash_on_root".  

With the proposed list of options I tried to do this


fos_js_routing:
  controller: ../../../src/Controller/

But I got another error

In FileLoader.php line 166:

  You must define a "path" for the route "fos_js_routing" in file "***\config\routes/fos_js_routing.yaml" in ***\config\routes/fos_js_routing.yaml (which is loaded in resource "***\config\routes/fos_js_routing.yaml").  

In YamlFileLoader.php line 262:

  You must define a "path" for the route "fos_js_routing" in file "***\config\routes/fos_js_routing.yaml".