This is my first time using FOSJsRoutingBundle, so I might have missed a step installing... But after double checking the docs a few times, I'm pretty sure I got it all set up correctly.
I have a Symfony 6.2 (php 8.1) app, running Webpack Encore. I know I have Encore setup correctly since my assets and stimulus controllers work. So I followed the installation steps for webpack.
Added the import statement and Encore.addPlugin(new FosRouting()); line to webpack.config.js.
Restarted npm run watch.
Then I tried using it in my Stimulus controller and kept getting "route does not exist" errors.
Eventually I tried just adding import Routing from 'fos-router'; and console.log(Routing.getRoutes()); to my app.js file in an attempt to see if there was something weird going on with Stimulus.
At this point all my console.log will output is an empty Array. Both from the app.js call, and when my Stimulus controller method runs. It also will output a "route does not exist" error for any route I try to generate a url for. And I'm using routes listed in debug:router. I've tried routes with and without parameters.
Any insight on what I'm doing wrong would be appreciated.
Would it make sense to explicitly state that users need to apply that option? It's not something that was obvious to me, even though I went through that doc several times.
This is my first time using FOSJsRoutingBundle, so I might have missed a step installing... But after double checking the docs a few times, I'm pretty sure I got it all set up correctly.
I have a Symfony 6.2 (php 8.1) app, running Webpack Encore. I know I have Encore setup correctly since my assets and stimulus controllers work. So I followed the installation steps for webpack.
composer require --ignore-platform-reqs friendsofsymfony/jsrouting-bundle
(Flex configured bundles.php)php bin/console assets:install --symlink public
(Er, is this really needed with Encore? Isn't everything compiled into different .js files?)npm install --save-dev ./vendor/friendsofsymfony/jsrouting-bundle/Resources
Encore.addPlugin(new FosRouting());
line towebpack.config.js
.npm run watch
.import Routing from 'fos-router';
andconsole.log(Routing.getRoutes());
to myapp.js
file in an attempt to see if there was something weird going on with Stimulus.At this point all my
console.log
will output is an empty Array. Both from theapp.js
call, and when my Stimulus controller method runs. It also will output a "route does not exist" error for any route I try to generate a url for. And I'm using routes listed indebug:router
. I've tried routes with and without parameters.Any insight on what I'm doing wrong would be appreciated.
Thanks in advance!