4 Applications that use Symfony Flex
 
   5 ----------------------------------
 
   7 Add bundle custom repository to your project's `composer.json` file:
 
  16                 "name": "rapsys/userbundle",
 
  17                 "version": "dev-master",
 
  20                     "url": "https://git.rapsys.eu/userbundle",
 
  25                         "Rapsys\\UserBundle\\": ""
 
  29                     "doctrine/doctrine-bundle": "^1.12",
 
  30                     "rapsys/packbundle": "dev-master",
 
  31                     "symfony/flex": "^1.5",
 
  32                     "symfony/form": "^4.4",
 
  33                     "symfony/framework-bundle": "^4.4",
 
  34                     "symfony/security-bundle": "^4.4",
 
  35                     "symfony/validator": "^4.4"
 
  44 Then open a command console, enter your project directory and execute:
 
  47 $ composer require rapsys/userbundle dev-master
 
  50 Applications that don't use Symfony Flex
 
  51 ----------------------------------------
 
  53 ### Step 1: Download the Bundle
 
  55 Open a command console, enter your project directory and execute the
 
  56 following command to download the latest stable version of this bundle:
 
  59 $ composer require rapsys/userbundle dev-master
 
  62 This command requires you to have Composer installed globally, as explained
 
  63 in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
 
  64 of the Composer documentation.
 
  66 ### Step 2: Enable the Bundle
 
  68 Then, enable the bundle by adding it to the list of registered bundles
 
  69 in the `app/AppKernel.php` file of your project:
 
  76 class AppKernel extends Kernel
 
  78     public function registerBundles()
 
  82             new Rapsys\UserBundle\RapsysUserBundle(),
 
  92 ### Step 3: Configure the Bundle
 
  94 Setup configuration file `config/packages/rapsys_user.yaml` with the following
 
  95 content available in `Rapsys/UserBundle/Resources/config/packages/rapsys_user.yaml`:
 
  98 #Doctrine configuration
 
 102         #Force resolution of UserBundle entities to CustomBundle one
 
 103         #XXX: without these lines, relations are lookup in parent namespace ignoring CustomBundle extension
 
 104         resolve_target_entities:
 
 105             Rapsys\UserBundle\Entity\Group: 'CustomBundle\Entity\Group'
 
 106             Rapsys\UserBundle\Entity\Civility: 'CustomBundle\Entity\Civility'
 
 107             Rapsys\UserBundle\Entity\User: 'CustomBundle\Entity\User'
 
 109 #RapsysUser configuration
 
 113         group: 'CustomBundle\Entity\Group'
 
 114         civility: 'CustomBundle\Entity\Civility'
 
 115         user: 'CustomBundle\Entity\User'
 
 125 #Service configuration
 
 127     #Register security context service
 
 128     rapsys_user.access_decision_manager:
 
 129         class: 'Symfony\Component\Security\Core\Authorization\AccessDecisionManager'
 
 131         arguments: [ [ '@security.access.role_hierarchy_voter' ] ]
 
 132     #Register default controller
 
 133     Rapsys\UserBundle\Controller\DefaultController:
 
 134         arguments: [ '@service_container', '@router', '@translator' ]
 
 136         tags: [ 'controller.service_arguments' ]
 
 137     #Register Authentication success handler
 
 138     security.authentication.success_handler:
 
 139         class: 'Rapsys\UserBundle\Handler\AuthenticationSuccessHandler'
 
 140         arguments: [ '@router', {} ]
 
 141     #Register Authentication failure handler
 
 142     security.authentication.failure_handler:
 
 143         class: 'Rapsys\UserBundle\Handler\AuthenticationFailureHandler'
 
 144         arguments: [ '@http_kernel', '@security.http_utils', {}, '@logger', '@service_container', '@router', '@rapsys_pack.slugger_util']
 
 145     #Register logout success handler
 
 146     security.logout.success_handler:
 
 147         class: 'Rapsys\UserBundle\Handler\LogoutSuccessHandler'
 
 148         arguments: [ '@service_container', '/', '@router' ]
 
 149     #Register security user checker
 
 150     security.user_checker:
 
 151         class: 'Rapsys\UserBundle\Checker\UserChecker'
 
 154 Open a command console, enter your project directory and execute the following
 
 155 command to see default bundle configuration:
 
 158 $ php bin/console config:dump-reference RapsysUserBundle
 
 161 Open a command console, enter your project directory and execute the following
 
 162 command to see current bundle configuration:
 
 165 $ php bin/console debug:config RapsysUserBundle
 
 168 ### Step 4: Setup custom bundle entities
 
 170 Setup configuration file `CustomBundle/Resources/config/doctrine/User.orm.yml` with the
 
 174 CustomBundle\Entity\User:
 
 176     #repositoryClass: CustomBundle\Repository\UserRepository
 
 190 Setup configuration file `Resources/config/doctrine/Group.orm.yml` with the
 
 194 CustomBundle\Entity\Group:
 
 196     #repositoryClass: CustomBundle\Repository\GroupRepository
 
 200             targetEntity: Rapsys\AirBundle\Entity\User
 
 204 Setup configuration file `Resources/config/doctrine/Civility.orm.yml` with the
 
 208 CustomBundle\Entity\Civility:
 
 210     #repositoryClass: CustomBundle\Repository\CivilityRepository
 
 218 Setup entity file `CustomBundle/Entity/User.php` with the following content:
 
 223 namespace CustomBundle\Entity;
 
 225 use Rapsys\UserBundle\Entity\User as BaseUser;
 
 227 class User extends BaseUser {}
 
 230 Setup entity file `CustomBundle/Entity/Group.php` with the following content:
 
 235 namespace CustomBundle\Entity;
 
 237 use Rapsys\GroupBundle\Entity\Group as BaseGroup;
 
 239 class Group extends BaseGroup {}
 
 242 Setup entity file `CustomBundle/Entity/Civility.php` with the following content:
 
 247 namespace CustomBundle\Entity;
 
 249 use Rapsys\CivilityBundle\Entity\Civility as BaseCivility;
 
 251 class Civility extends BaseCivility {}