]> Raphaƫl G. Git Repositories - userbundle/blob - README.md
Rename user bundle route alias
[userbundle] / README.md
1 Contribute
2 ==========
3
4 You may buy me a Beer, a Tea or help with Server fees with a paypal donation to
5 the address <paypal@rapsys.eu>.
6
7 Don't forget to show your love for this project, feel free to report bugs to
8 the author, issues which are security relevant should be disclosed privately
9 first.
10
11 Patches are welcomed and grant credit when requested.
12
13 Installation
14 ============
15
16 Applications that use Symfony Flex
17 ----------------------------------
18
19 Add bundle custom repository to your project's `composer.json` file:
20
21 ```json
22 {
23 ...,
24 "repositories": [
25 {
26 "type": "package",
27 "package": {
28 "name": "rapsys/userbundle",
29 "version": "dev-master",
30 "source": {
31 "type": "git",
32 "url": "https://git.rapsys.eu/userbundle",
33 "reference": "master"
34 },
35 "autoload": {
36 "psr-4": {
37 "Rapsys\\UserBundle\\": ""
38 }
39 },
40 "require": {
41 "doctrine/doctrine-bundle": "^1.0|^2.0",
42 "rapsys/packbundle": "dev-master",
43 "symfony/flex": "^1.0",
44 "symfony/form": "^4.0|^5.0",
45 "symfony/framework-bundle": "^4.0|^5.0",
46 "symfony/security-bundle": "^4.0|^5.0",
47 "symfony/validator": "^4.0|^5.0"
48 }
49 }
50 }
51 ],
52 ...
53 }
54 ```
55
56 Then open a command console, enter your project directory and execute:
57
58 ```console
59 $ composer require rapsys/userbundle dev-master
60 ```
61
62 Applications that don't use Symfony Flex
63 ----------------------------------------
64
65 ### Step 1: Download the Bundle
66
67 Open a command console, enter your project directory and execute the
68 following command to download the latest stable version of this bundle:
69
70 ```console
71 $ composer require rapsys/userbundle dev-master
72 ```
73
74 This command requires you to have Composer installed globally, as explained
75 in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
76 of the Composer documentation.
77
78 ### Step 2: Enable the Bundle
79
80 Then, enable the bundle by adding it to the list of registered bundles
81 in the `app/AppKernel.php` file of your project:
82
83 ```php
84 <?php
85 // app/AppKernel.php
86
87 // ...
88 class AppKernel extends Kernel
89 {
90 public function registerBundles()
91 {
92 $bundles = array(
93 // ...
94 new Rapsys\UserBundle\RapsysUserBundle(),
95 );
96
97 // ...
98 }
99
100 // ...
101 }
102 ```
103
104 ### Step 3: Configure the Bundle
105
106 Setup configuration file `config/packages/rapsys_user.yaml` with the following
107 content available in `Rapsys/UserBundle/Resources/config/packages/rapsys_user.yaml`:
108
109 ```yaml
110 #Doctrine configuration
111 doctrine:
112 #Orm configuration
113 orm:
114 #Force resolution of UserBundle entities to CustomBundle one
115 #XXX: without these lines, relations are lookup in parent namespace ignoring CustomBundle extension
116 resolve_target_entities:
117 Rapsys\UserBundle\Entity\Group: 'CustomBundle\Entity\Group'
118 Rapsys\UserBundle\Entity\Civility: 'CustomBundle\Entity\Civility'
119 Rapsys\UserBundle\Entity\User: 'CustomBundle\Entity\User'
120
121 #RapsysUser configuration
122 rapsys_user:
123 #Class replacement
124 class:
125 group: 'CustomBundle\Entity\Group'
126 civility: 'CustomBundle\Entity\Civility'
127 user: 'CustomBundle\Entity\User'
128 #Default replacement
129 default:
130 group: [ 'User' ]
131 civility: 'Mister'
132 #Route replacement
133 route:
134 index:
135 name: 'custom_index'
136
137 #Service configuration
138 services:
139 #Register security context service
140 rapsys_user.access_decision_manager:
141 class: 'Symfony\Component\Security\Core\Authorization\AccessDecisionManager'
142 public: true
143 arguments: [ [ '@security.access.role_hierarchy_voter' ] ]
144 #Register default controller
145 Rapsys\UserBundle\Controller\DefaultController:
146 arguments: [ '@service_container', '@router', '@translator' ]
147 autowire: true
148 tags: [ 'controller.service_arguments' ]
149 #Register Authentication success handler
150 security.authentication.success_handler:
151 class: 'Rapsys\UserBundle\Handler\AuthenticationSuccessHandler'
152 arguments: [ '@router', {} ]
153 #Register Authentication failure handler
154 security.authentication.failure_handler:
155 class: 'Rapsys\UserBundle\Handler\AuthenticationFailureHandler'
156 arguments: [ '@http_kernel', '@security.http_utils', {}, '@logger', '@service_container', '@router', '@rapsys_pack.slugger_util']
157 #Register logout success handler
158 security.logout.success_handler:
159 class: 'Rapsys\UserBundle\Handler\LogoutSuccessHandler'
160 arguments: [ '@service_container', '/', '@router' ]
161 #Register security user checker
162 security.user_checker:
163 class: 'Rapsys\UserBundle\Checker\UserChecker'
164 ```
165
166 Open a command console, enter your project directory and execute the following
167 command to see default bundle configuration:
168
169 ```console
170 $ php bin/console config:dump-reference RapsysUserBundle
171 ```
172
173 Open a command console, enter your project directory and execute the following
174 command to see current bundle configuration:
175
176 ```console
177 $ php bin/console debug:config RapsysUserBundle
178 ```
179
180 ### Step 4: Setup custom bundle entities
181
182 Setup configuration file `CustomBundle/Resources/config/doctrine/User.orm.yml` with the
183 following content:
184
185 ```yaml
186 CustomBundle\Entity\User:
187 type: entity
188 #repositoryClass: CustomBundle\Repository\UserRepository
189 table: users
190 associationOverride:
191 groups:
192 joinTable:
193 name: users_groups
194 joinColumns:
195 id:
196 name: user_id
197 inverseJoinColumns:
198 id:
199 name: group_id
200 ```
201
202 Setup configuration file `Resources/config/doctrine/Group.orm.yml` with the
203 following content:
204
205 ```yaml
206 CustomBundle\Entity\Group:
207 type: entity
208 #repositoryClass: CustomBundle\Repository\GroupRepository
209 table: groups
210 manyToMany:
211 users:
212 targetEntity: Rapsys\AirBundle\Entity\User
213 mappedBy: groups
214 ```
215
216 Setup configuration file `Resources/config/doctrine/Civility.orm.yml` with the
217 following content:
218
219 ```yaml
220 CustomBundle\Entity\Civility:
221 type: entity
222 #repositoryClass: CustomBundle\Repository\CivilityRepository
223 table: civilities
224 oneToMany:
225 users:
226 targetEntity: User
227 mappedBy: civility
228 ```
229
230 Setup entity file `CustomBundle/Entity/User.php` with the following content:
231
232 ```php
233 <?php
234
235 namespace CustomBundle\Entity;
236
237 use Rapsys\UserBundle\Entity\User as BaseUser;
238
239 class User extends BaseUser {}
240 ```
241
242 Setup entity file `CustomBundle/Entity/Group.php` with the following content:
243
244 ```php
245 <?php
246
247 namespace CustomBundle\Entity;
248
249 use Rapsys\GroupBundle\Entity\Group as BaseGroup;
250
251 class Group extends BaseGroup {}
252 ```
253
254 Setup entity file `CustomBundle/Entity/Civility.php` with the following content:
255
256 ```php
257 <?php
258
259 namespace CustomBundle\Entity;
260
261 use Rapsys\CivilityBundle\Entity\Civility as BaseCivility;
262
263 class Civility extends BaseCivility {}
264 ```