@@ -96,7 +96,59 @@ optional features, like :doc:`remember me </security/remember_me>` and
96
96
:doc: `impersonation </security/impersonating_user >`.
97
97
98
98
Fortunately, the ``make:user `` command already configured one for you in your
99
- ``security.yaml `` file under the ``providers `` key.
99
+ ``security.yaml `` file under the ``providers `` key:
100
+
101
+ .. configuration-block ::
102
+
103
+ .. code-block :: yaml
104
+
105
+ # config/packages/security.yaml
106
+ security :
107
+ # ...
108
+
109
+ providers :
110
+ # used to reload user from session & other features (e.g. switch_user)
111
+ app_user_provider :
112
+ entity :
113
+ class : App\Entity\User
114
+ property : email
115
+
116
+ .. code-block :: xml
117
+
118
+ <!-- config/packages/security.xml -->
119
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
120
+ <srv : container xmlns =" http://symfony.com/schema/dic/security"
121
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
122
+ xmlns : srv =" http://symfony.com/schema/dic/services"
123
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
124
+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
125
+
126
+ <config >
127
+ <!-- used to reload user from session & other features (e.g. switch-user) -->
128
+ <provider name =" app_user_provider" >
129
+ <entity class =" App\Entity\User" property =" email" />
130
+ </provider >
131
+ </config >
132
+ </srv : container >
133
+
134
+ .. code-block :: php
135
+
136
+ // config/packages/security.php
137
+ use App\Entity\User;
138
+
139
+ $container->loadFromExtension('security', [
140
+ // ...
141
+
142
+ 'providers' => [
143
+ // used to reload user from session & other features (e.g. switch_user)
144
+ 'app_user_provider' => [
145
+ 'entity' => [
146
+ 'class' => User::class,
147
+ 'property' => 'email',
148
+ ],
149
+ ],
150
+ ],
151
+ ]);
100
152
101
153
If your ``User `` class is an entity, you don't need to do anything else. But if
102
154
your class is *not * an entity, then ``make:user `` will also have generated a
0 commit comments