miltone
miltone

Reputation: 4721

configure FosJsRoutingBundle with Symfony4

I would like to use FosJsRoutingBundle with my Symfony4 project.


I already have use this bundle and this integration with symfony is very easy et quickly. But with Symfony4 I have a strange issue for loading all expose route symfony into JavaScript script.


My version of FosJsRoutingBundle : "friendsofsymfony/jsrouting-bundle": "^2.2",

I have include my 2 script javascript into head layout page for loading config and routes :

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

My fos_js_routing.yaml configuration file :

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

My structure of public folder symfony project : enter image description here

And my issue throw when I call my web page :

Failed on loading for element which source is  

http://xxxx.xxxxx.xxxxx/js/routing?callback=fos.Router.setData ».


How can load correctly this bundle with new symfony4 project structure ?

Upvotes: 0

Views: 1365

Answers (1)

Joachim
Joachim

Reputation: 320

Have you published the Assets?

Symfony 4 isn't described there, but I think you will have to issue

php bin/console assets:install --symlink public

The «web» directory isn't a part of v4.

Upvotes: 1

Related Questions