i'm using symfony 2.8.6. and FOSUserBundle to setup a very simple website. there is a route for "/" to display my HomeController and i was wondering if its possible to have "/username" go to a ProfileControler which shows the appropriate user. how does the route have to be configured? can it even be in the root url or does it have to be "/user/username" which is ugly...
So far FOSUserBundle allows all sorts of characters in a username, which would not be very much compatible with a url. So upon user creation i would have to create a unique perma-url for the username. How would I go about doing this? How do i check for the unique-ness of the permaurl in the database?
Thank you for your help.
If you use the username as part of the url, the FosUserBundle and the database cares about duplicates, so you don't need to care about that.
To create the public part you can use the HomeController and the @Route annotation with the /{username} password or configure the pattern in the routing.yml as shown in documentation.
This will be a headache soon as this pattern will capture almost any thing like /about-us and will look for it in the database, so I would recommend you move to a "section" like /users/{username} even is ugly.
If you want to avoid this, you have to play with the order that you configure your routes in the routing.yml file. The more specific the pattern is the sooner it should appear in the yml file