I can never remember this command. However, now that I am creating more AJAX and exposing endpoints I need this command more often.
This command is found in the docs too. But I can never remember where, so I will write about it here.
The command to view how FosJsRoutingBundle views your routes.
php bin/console fos:js-routing:debug
This will list something like this for you.
Name | Method | Scheme | Host | Path | +-----------------------+--------+--------+------+------------------------+ | menu | GET | ANY | ANY | /menu | | alias_exists | ANY | ANY | ANY | /alias_exists | | email_exists | ANY | ANY | ANY | /email_exists | | get_image_collections | GET | ANY | ANY | /get_image_collections | | save_user_image | POST | ANY | ANY | /save_user_image | | get_user_image_data | GET | ANY | ANY | /get_user_image_data | +-----------------------+--------+--------+------+------------------------+
Isn’t that pretty.This is not dynamically updated. You need to re-output your routes to the file FosJSRoutingBundle expects them to be in, so that when it creates a route it matches. I need to write an article about how to do only that. For now scroll to the bottom of the following article. How to get URL Routes in your Javascript in Symfony 5+
But if you don’t update your routes they won’t match the above output and your routes will fail when you use FosJS. Mine seemed to just redirect to my current page. Your setup/configs may differ.
Comments
You must log in to post a comment.