How to go further after a basic installation of FosUserBundle

In this article, I suppose you have installed FosUserBundle (in composer.json : “friendsofsymfony/user-bundle”: “dev-master”).  I also suppose that your symfony project is working (services enabled, security.yml configured, your bundle extends FOSUserBundle etc.)

Overriding themes:

  1. Take a look in FOS\UserBundle\Ressources\views\
  2. You will find all the templates that you need. To override one of them, simply create in your bundle, a file keeping the same path (i.e. Acme\UserBundle\Ressources\views\Security\login.html.twig). You can write everything you want inside.
  3. NB: The layout for FOSUserBundle is FOS\UserBundle\Ressources\views\layout.html.twig You can override it if necessary, at least to extend yours.

 

Overriding forms:

  1. Create a new file under Acme\UserBundle\Form\
  2. One more time you can take a look in “FOS\UserBundle\Form\” to keep the same name. It can help you to keep your files organized. Put whatever you need inside. Don’t forget to add “parent::buildForm($builder, $options);”
  3. Add a service corresponding to your newly created class. To avoid any mistakes go to the doc of FOSUB
  4. Declare your new form in config.yml

 

Reference:

FOSUserBundle doc Templates : https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_templates.md

FOSUserBundle doc Forms: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_forms.md

 

Leave a Reply

Your email address will not be published. Required fields are marked *