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.


Share This Episode

If you have found this video helpful, please consider sharing. I really appreciate it.


Episodes in this series

# Title Duration
1 Getting Started with FOSUserBundle 06:53
2 Your Fully Functioning User Management System 05:13
3 FOSUserBundle and Bootstrap 3 Template Customisation 05:50
4 Login with Username or Email Address 03:04
5 FOSUserBundle with Bootstrap 3 Sign In Form 05:08
6 Adding Remember Me Functionality to FOSUserBundle 07:32
7 FOSUserBundle and the Bootstrap Navbar 09:11
7 Email Management and Template Customisation 09:32
8 Impersonating a Different User 05:15
9 Translations and Internationalisation in FOSUserBundle 08:22
10 How to Redirect a User After Login or Registration 07:20
11 UX Improvements - Part 1 - Redirect /login when Logged In 08:31
12 UX Improvements - Part 2 - Redirect Using an Event Listener 15:06
13 How to Disable Registation in FOSUserBundle 09:31
14 Mailchimp Integration with FOSUserBundle Events 15:09