Your Fully Functioning User Management System
In the first video we installed FOSUserBundle, created our first User
, and learned about the concept of Roles. In this video we are going to explore some of that new functionality that FOSUserBundle has given us.
As part of the installation process for FOSUserBundle, we import a list of Symfony routes which makes available a number of additional paths on our website:
# app/config/routing.yml
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
To make your Symfony development even more enjoyable, if you are using PHPStorm, I would highly advise installing the Symfony2 plugins, as we will use them frequently throughout not just this series, but during our development in general.
One of these plugins gives us clickable views which makes navigating third party routes a breeze.
Once we have imported this top level route, our application gains the following routes:
php app/console debug:router
[router] Current routes
Name Method Scheme Host Path
fos_user_security_login GET|POST ANY ANY /login
fos_user_security_check POST ANY ANY /login_check
fos_user_security_logout GET ANY ANY /logout
fos_user_profile_show GET ANY ANY /profile/
fos_user_profile_edit GET|POST ANY ANY /profile/edit
fos_user_registration_register GET|POST ANY ANY /register/
fos_user_registration_check_email GET ANY ANY /register/check-email
fos_user_registration_confirm GET ANY ANY /register/confirm/{token}
fos_user_registration_confirmed GET ANY ANY /register/confirmed
fos_user_resetting_request GET ANY ANY /resetting/request
fos_user_resetting_send_email POST ANY ANY /resetting/send-email
fos_user_resetting_check_email GET ANY ANY /resetting/check-email
fos_user_resetting_reset GET|POST ANY ANY /resetting/reset/{token}
fos_user_change_password GET|POST ANY ANY /profile/change-password
# other routes here
This is pretty fantastic.
For the sake of a few minutes of effort in terms of installation, we now have a fully working, customisable and configurable, well-tested user management system.
We can visit each of these routes immediately, and they will all work and behave just as you would expect.
What's even cooler is that whilst not immediately obvious, should you go ahead and visit your shiny new /register/
path, you can register a new User
, and not only will that work, but you also get a friendly welcome email sent to you as part of the process.
To keep things as generic as possible, FOSUserBundle templates are largely unstyled. We will look at how you can edit all these templates, even including the various email templates (registration, password reset, etc), in forthcoming videos.