From symfony 4, I used the bundle jsrouting for get symfony route path from JS code. In dev
environment all works fine, but when I set the symfony configuration to prod
mod I get this error when I load a page where one of my javascript scrips use jsrouting :
(error occured in a custom javascript file global.js
used by my page)
My twig file contains theses lines :
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
<script src="{{ asset('build/js/us/builder/global.js') }}"></script>
APP_ENV
to dev
in .env file : when I load the page, from the browser debugger I see : APP_ENV
to prod
in .env file : when I load the page, from the browser debugger I see : I don't understand why when I go to prod
mode, these two lines :
<script src="/*****/public/bundles/fosjsrouting/js/router.js"></script>
<script src="/*****/public/js/routing?callback=fos.Router.setData"></script>
are missing...and this is why I got the error "Routing is not defined", because "Routing" is defined in the router.js file .
I don't understand why theses lines are missing when Symfony is in the prod
environment
The content of my config file /myproject/config/bundles.php
:
<?php
return [
//...
FOS\JsRoutingBundle\FOSJsRoutingBundle::class => ['all' => true],
];
EDIT The output of some console commands :
Look carefully at your var directories, sub-directories permission and owner.
php bin/console cache:pool:clear cache.global_clearer
chmod -R 777 var/log
put the right owner for the prod directory:
cache/prod
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.