Symfony2外掛FOSUserBundle的使用說明
Provides user persistence for your Symfony2 Project.
為您的Symfony2專案提供使用者持久化
Features
功能
========
– Compatible with Doctrine ORM **and** ODM thanks to a generic repository.
– 與Doctrine ORM **和** ODM 相容,這歸功於通用庫
– Model is extensible at will
– 模型可隨意擴充套件
– REST-ful authentication
– REST風格的認證
– Current user available in your controllers and views
– 當前使用者在您控制器和檢視中可用
– Unit tested and functionally tested
– 支援單元測試和功能測試
Warning
警告
=======
The core SecurityBundle is required to use this bundle.
使用該Bundle必須啟用核心SecurityBundle。
The supplied Controller and routing configuration files expose as much functionality as possible to illustrate how to use the Bundle. However using these exposes a lot of functionality which requires additional configuration to secure properly (for example delete, list etc). As such its not recommended to ever go into production while using one of the default routing configuration files.
為了說明如何使用該Bundle,其所提供的Controller和路由配置檔案都儘可能多地展示功能。然而,展示大量這樣的功能是需要額外的配置來確保安全的(如刪除和列表等)。因此,並不建議在生產環境中使用某種預設的路由配置檔案。
The implementation of ACL checks via the JMSSecurityExtraBundle is also
currently incomplete (see issue #53) and activation of this Bundle is also
not enforced.
通過JMSSecurityExtraBundle實現ACL檢查當前還不完整(參見問題#53),也並不強制啟用該Bundle。
Furthermore it may be necessary to extend or even replace the default Controllers
with custom code to achieve the exact desired behavior. Trying to cover every possible use case is not feasible as it would complicate the Bundle to the point of being unmaintainable and impossible to comprehend in a reasonable amount of time.
此外,它也許會用自定義程式碼去擴充套件甚至替換預設的控制器,以實現確實想要的行為。試圖涵蓋所有可能的用例是不現實的,因為它會使Bundle變得複雜,從而使之在合理的時間內變得不可維護和難以理解。
Installation
安裝
============
Add FOSUserBundle to your vendor/bundles/ dir
將FOSUserBundle新增到您的vendor/bundles/目錄中
——————————————
Using the vendors script
使用vendors指令碼
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Add the following lines in your “deps“ file
新增以下語句到您的“deps“檔案中
::
[FOSUserBundle]
git=git://github.com/FriendsOfSymfony/FOSUserBundle.git
target=bundles/FOS/UserBundle
Run the vendors script
執行vendors指令碼
::
./bin/vendors install
Using submodules
使用子模組
~~~~~~~~~~~~~~~~
::
$ git submodule add git://github.com/FriendsOfSymfony/FOSUserBundle.git vendor/bundles/FOS/UserBundle
Add the FOS namespace to your autoloader
將FOS名稱空間新增到您的自動載入器中
—————————————-
::
// app/autoload.php
$loader->registerNamespaces(array(
`FOS` => __DIR__.`/../vendor/bundles`,
// your other namespaces
);
Add UserBundle to your application kernel
將UserBundle新增到您的應用程式核心中
—————————————–
::
// app/AppKernel.php
public function registerBundles()
{
return array(
new SymfonyBundleSecurityBundleSecurityBundle(),
// …
new FOSUserBundleFOSUserBundle(),
// …
);
}
Create your User class
建立您的User類
———————-
You must create a User class that extends either the entity or document abstract
User class in UserBundle. All fields on the base class are mapped, except for
“id“; this is intentional, so you can select the generator that best suits
your application. Feel free to add additional properties and methods to your
custom class.
您必須建立一個User類去擴充套件UserBundle中的實體或文件抽象User類。除了“id“,基類中的所有欄位都被對映;這是故意的,以便您可以選擇您應用程式最適用的生成器。您可以向您自定義的類中隨意新增額外的屬性和方法。
ORM User class
ORM User類
~~~~~~~~~~~~~~
::
// src/MyProject/MyBundle/Entity/User.php
<?php
namespace MyProjectMyBundleEntity;
use FOSUserBundleEntityUser as BaseUser;
use DoctrineORMMapping as ORM;
/**
* @ORMEntity
* @ORMTable(name=”fos_user”)
*/
class User extends BaseUser
{
/**
* @ORMId
* @ORMColumn(type=”integer”)
* @ORMgeneratedValue(strategy=”AUTO”)
*/
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
.. note
.. 注意
::
“User“ is a reserved keyword in SQL so you cannot use it as table name.
“User“是SQL中的保留關鍵詞,因此您不能將其作為資料表名。
MongoDB User class
MongoDB User類
~~~~~~~~~~~~~~~~~~
::
// src/MyProject/MyBundle/Document/User.php
<?php
namespace MyProjectMyBundleDocument;
use FOSUserBundleDocumentUser as BaseUser;
use DoctrineODMMongoDBMappingAnnotations as MongoDB;
/**
* @MongoDBDocument
*/
class User extends BaseUser
{
/** @MongoDBId(strategy=”auto”) */
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
.. warning
.. 警告
::
Take care to call the parent constructor when you overwrite it in your own
entity as it initializes some fields.
當您為了初始化某些欄位而在您自己的實體類中覆寫了建構函式時,請小心呼叫父類的建構函式。
Configure your project
配置您的專案
———————-
The UserBundle works with the Symfony Security Component, so make sure that is enabled in your kernel and in your project`s configuration. A working security configuration using FOSUserBundle is available at the end of the doc.
UserBundle需要Symfony2的安全元件才能正常工作,因此請確保在您的核心和專案配置中啟用了它。在本文件結束時,將向您展示一個可正常工作的使用FOSUserBundle的安全配置。
.. note
.. 注意
::
You need to activate SwiftmailerBundle to be able to use the functionalities
using emails (confirmation of the account, resetting of the password).
See the `Emails` section to know how using another mailer.
你需要啟用SwiftmailerBundle來使用要電子郵件協助的功能(如帳號確認、密碼重置等)
The login form and all the routes used to create a user and reset the password
have to be available to unauthenticated users but using the same firewall as
the pages you want to securize with the bundle. Assuming you import the
registration.xml routing file with the “/register“ prefix and resetting.xml
with the “/resetting“ prefix they will be
登入表單和所有用於建立使用者和重置密碼的路由都要向未經認證的使用者開放,但使用同一防火牆,因為您要確保整個Bundle頁面的安全。假設您準備使用“/register“字首匯入registration.xml路由檔案,使用“/register“字首匯入resetting.xml。
::
/login
/register/
/register/check-email
/register/confirm/{token}
/register/confirmed
/resetting/request
/resetting/send-email
/resetting/check-email
/resetting/reset/{token}
The above example assumes an ORM configuration, but the “mappings“
configuration block would be the same for MongoDB ODM.
上面的例子假設使用的是ORM配置,但對於MongoDB ODM來講“mappings“配置區塊也能達到相同的效果。
Minimal configuration
最小配置
———————
At a minimum, your configuration must define your DB driver (“orm” or “mongodb”), a User class and the firewall name. The firewall name matches the key in the firewall configuration that is used for users with the controllers of the
bundle.
至少,您的配置需要定義您的資料庫驅動(”orm”或”mongodb”)、User類和防火牆名。防火牆名匹配防火牆配置中的關鍵詞,該配置用於Bundle控制器的使用者。
The firewall name needs to be configured so that the FOSUserBundle can determine against which firewall the user should be authenticated after activating the account for instance. This means that out of the box FOSUserBundle only supports being used for a single firewall, though with a custom Controller this
limitation can be circumvented.
配置防火牆名稱是為了讓FOSUserBundle可以確定使用者帳戶例項啟用後確定使用哪個防火牆來進行認證。這就意味著FOSUserBundle僅被支援用於單個防火牆,雖然通過自定義控制器可以規避該限制。
For example for a security configuration like the following the firewall_name
would have to be set to “main”, as shown in the proceeding examples:
接下來是安全配置的例子,firewall_name必須設為”main”,如下所示:
::
# app/config/config.yml
security:
providers:
fos_userbundle:
id: fos_user.user_manager
firewalls:
main:
form_login:
provider: fos_userbundle
ORM
~~~
In YAML:
YAML格式:
::
# app/config/config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: MyProjectMyBundleEntityUser
Or if you prefer XML:
如果你喜歡XML格式:
::
# app/config/config.xml
<fos_user:config
db-driver=”orm”
firewall-name=”main”
user-class=”MyProjectMyBundleEntityUser”
/>
ODM
~~~
In YAML:
YAML格式:
::
# app/config/config.yml
fos_user:
db_driver: mongodb
firewall_name: main
user_class: MyProjectMyBundleDocumentUser
Or if you prefer XML:
如果你喜歡XML格式:
::
# app/config/config.xml
<fos_user:config
db-driver=”mongodb”
firewall-name=”main”>
user-class=”MyProjectMyBundleDocumentUser”
/>
Add authentication routes
新增認證路由
————————-
If you want ready to use login and logout pages, include the built-in
routes:
如果你想使用包含內建路由的登入和退出頁:
::
# app/config/routing.yml
fos_user_security:
resource: “@FOSUserBundle/Resources/config/routing/security.xml”
fos_user_profile:
resource: “@FOSUserBundle/Resources/config/routing/profile.xml”
prefix: /profile
fos_user_register:
resource: “@FOSUserBundle/Resources/config/routing/registration.xml”
prefix: /register
fos_user_resetting:
resource: “@FOSUserBundle/Resources/config/routing/resetting.xml”
prefix: /resetting
fos_user_change_password:
resource: “@FOSUserBundle/Resources/config/routing/change_password.xml”
prefix: /change-password
::
# app/config/routing.xml
<import resource=”@FOSUserBundle/Resources/config/routing/security.xml”/>
<import resource=”@FOSUserBundle/Resources/config/routing/profile.xml” prefix=”/profile” />
<import resource=”@FOSUserBundle/Resources/config/routing/registration.xml” prefix=”/register” />
<import resource=”@FOSUserBundle/Resources/config/routing/resetting.xml” prefix=”/resetting” />
<import resource=”@FOSUserBundle/Resources/config/routing/change_password.xml” prefix=”/change-password” />
You now can login at http://app.com/app_dev.php/login
現在您可以通過http://app.com/app_dev.php/login登入了。
Command line
命令列
============
FOSUserBundle provides command line utilities to help manage your
application users.
FOSUserBundle提供命令列工具來幫助您管理您的管理程式使用者。
Create user
建立使用者
———–
This command creates a new user
該命令新建一個使用者
::
$ php app/console fos:user:create username email password
If you don`t provide the required arguments, a interactive prompt will
ask them to you
如果您不能提供所需的引數,將出現詢問您的提示
::
$ php app/console fos:user:create
Promote user as a super administrator
將使用者提升為超級管理員
————————————-
This command promotes a user as a super administrator
該命令將使用者提升為超級管理員
::
$ php app/console fos:user:promote
User manager service
使用者管理服務
====================
FOSUserBundle works with both ORM and ODM. To make it possible, it wraps
all the operation on users in a UserManager. The user manager is a service
of the container.
FOSUserBundle可以與ORM或ODM一起工作。為了使之成為可能,它在UserManager中封裝了與使用者相關的所有操作。
If you configure the db_driver to orm, this service is an instance of
“FOSUserBundleEntityUserManager“.
如果您將db_driver配置為orm,該服務是“FOSUserBundleEntityUserManager“的一個例項。
If you configure the db_driver to odm, this service is an instance of
“FOSUserBundleDocumentUserManager“.
如果您將db_driver配置為odm,該服務就是“FOSUserBundleDocumentUserManager“的一個例項。
Both these classes implement “FOSUserBundleModelUserManagerInterface“.
上述兩個類都實現了“FOSUserBundleModelUserManagerInterface“介面。
Access the user manager service
訪問使用者管理服務
——————————-
If you want to manipulate users in a way that will work as well with
ORM and ODM, use the fos_user.user_manager service
如果您想用一種方式操作使用者,該方式能夠使ORM或ODM都良好工作,那麼使用fos_user.user_manager服務
::
$userManager = $container->get(`fos_user.user_manager`);
That`s the way FOSUserBundle`s internal controllers are built.
這是建立FOSUserBundle內部控制器的方式。
Access the current user class
訪問當前使用者類
—————————–
A new instance of your User class can be created by the user manager
通過使用者管理器建立您User類的新例項
::
$user = $userManager->createUser();
`$user` is now an Entity or a Document, depending on the configuration.
`$user`現在是一個Entity或Document,這取決於配置。
Updating a User object
更新使用者物件
———————-
When creating or updating a User object you need to update the encoded password and the canonical fields. To make it easier, the bundle comes with a Doctrine listener handling this for you behind the scene.
當建立或更新使用者物件時,您需要更新加密的密碼和規範的欄位。為了使這一切變得容易,該Bundle自帶的Doctrine監聽器將為您在幕後處理這一切。
If you don`t want to use the Doctrine listener, you can disable it. In this case
you will have to call the “updateUser“ method of the user manager each time
you do a change in your entity.
如果您不想使用Doctrine監聽器,您也可以禁用它。在這種情況下,當您每次改變您的實體時,您都將不得不呼叫使用者管理器的“updateUser“方法。
In YAML:
YAML格式:
::
# app/config/config.yml
fos_user:
db_driver: orm
firewall_name: main
use_listener: false
user_class: MyProjectMyBundleEntityUser
Or if you prefer XML:
如果您喜歡XML格式:
::
# app/config/config.xml
<fos_user:config
db-driver=”orm”
firewall-name=”main”
use-listener=”false”>
user-class=”MyProjectMyBundleEntityUser”
/>
.. note
.. 注意
::
The default behavior is to flush the changes when calling this method. You
can disable the flush when using the ORM and the MongoDB implementations by
passing a second argument set to “false“.
當呼叫該方法時,其預設動作是去”flush”改變。您可以將該方法的第二個引數設為“false“,從而在使用ORM或MongoDB實現時禁用”flush”。
Using groups
使用組
============
The bundle allows to optionnally use groups. You need to explicitly
enable it in your configuration by giving the Group class which must
implement “FOSUserBundleModelGroupInterface“.
可以讓該Bundle選擇使用組。您需要通過指定的Group類在您的配置中明確地啟用它,Group類必須實現“FOSUserBundleModelGroupInterface“介面。
In YAML:
YAML格式:
::
# app/config/config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: MyProjectMyBundleEntityUser
group:
group_class: MyProjectMyBundleEntityGroup
Or if you prefer XML:
如果您喜歡XML格式:
::
# app/config/config.xml
<fos_user:config
db-driver=”orm”
firewall-name=”main”>
user-class=”MyProjectMyBundleEntityUser”
>
<fos_user:group group-class model=”MyProjectMyBundleEntityGroup” />
</fos_user:config>
The Group class
Group類
—————
The simpliest way is to extend the mapped superclass provided by the
bundle.
最簡單的方式就是擴充套件由該Bundle提供的對映超類
ORM
~~~
::
// src/MyProject/MyBundle/Entity/Group.php
<?php
namespace MyProjectMyBundleEntity;
use FOSUserBundleEntityGroup as BaseGroup;
use DoctrineORMMapping as ORM;
/**
* @ORMEntity
* @ORMTable(name=”fos_group”)
*/
class Group extends BaseGroup
{
/**
* @ORMId
* @ORMColumn(type=”integer”)
* @ORMgeneratedValue(strategy=”AUTO”)
*/
protected $id;
}
.. note
.. 注意
::
“Group“ is also a reserved keyword in SQL so it cannot be used either.
“Group“也是SQL的保留關鍵詞,因此它也不能使用。
ODM
~~~
::
// src/MyProject/MyBundle/Document/Group.php
<?php
namespace MyProjectMyBundleDocument;
use FOSUserBundleDocumentGroup as BaseGroup;
use DoctrineODMMongoDBMapping as MongoDB;
/**
* @MongoDBDocument
*/
class Group extends BaseGroup
{
/** @MongoDBId(strategy=”auto”) */
protected $id;
}
Defining the relation
定義關係
———————
The next step is to map the relation in your User class.
下一步就是要對映您User類的關係
ORM
~~~
::
// src/MyProject/MyBundle/Entity/User.php
<?php
namespace MyProjectMyBundleEntity;
use FOSUserBundleEntityUser as BaseUser;
use DoctrineORMMapping as ORM;
/**
* @ORMEntity
* @ORMTable(name=”fos_user”)
*/
class User extends BaseUser
{
/**
* @ORMId
* @ORMColumn(type=”integer”)
* @ORMgeneratedValue(strategy=”AUTO”)
*/
protected $id;
/**
* @ORMManyToMany(targetEntity=”MyProjectMyBundleEntityGroup”)
* @ORMJoinTable(name=”fos_user_user_group”,
* joinColumns={@ORMJoinColumn(name=”user_id”, referencedColumnName=”id”)},
* inverseJoinColumns={@ORMJoinColumn(name=”group_id”, referencedColumnName=”id”)}
* )
*/
protected $groups;
}
ODM
~~~
::
// src/MyProject/MyBundle/Document/User.php
<?php
namespace MyProjectMyBundleDocument;
use FOSUserBundleDocumentUser as BaseUser;
use DoctrineODMMongoDBMapping as MongoDB;
/**
* @MongoDBDocument
*/
class User extends BaseUser
{
/** @MongoDBId(strategy=”auto”) */
protected $id;
/** @MongoDBReferenceMany(targetDocument=”MyProjectMyBundleDocumentGroup”) */
protected $groups;
}
Enabling the routing for the GroupController
為GroupController啟用路由
——————————————–
You can also the group.xml file to use the builtin controller to manipulate the
groups.
您也可以通過group.xml檔案使用內建的控制器來維護組。
Configuration reference
配置參考
=======================
All configuration options are listed below
以下列出所有配置選項
::
# app/config/config.yml
fos_user:
db_driver: ~ # Required
firewall_name: ~ # Required
user_class: ~ # Required
use_listener: true
from_email: { webmaster@example.com: Admin }
profile:
form:
type: FOSUserBundleFormProfileFormType
handler: FOSUserBundleFormProfileFormHandler
name: fos_user_profile_form
validation_groups: [Profile]
change_password:
form:
type: FOSUserBundleFormChangePasswordFormType
handler: FOSUserBundleFormChangePasswordFormHandler
name: fos_user_change_password_form
validation_groups: [ChangePassword]
registration:
confirmation:
from_email: ~
enabled: false
template: FOSUserBundle:Registration:email.txt.twig
form:
type: FOSUserBundleFormRegistrationFormType
handler: FOSUserBundleFormRegistrationFormHandler
name: fos_user_registration_form
validation_groups: [Registration]
resetting:
token_ttl: 86400
email:
from_email: ~
template: FOSUserBundle:Resetting:email.txt.twig
form:
type: FOSUserBundleFormResettingFormType
handler: FOSUserBundleFormResettingFormHandler
name: fos_user_resetting_form
validation_groups: [ResetPassword]
service:
mailer: fos_user.util.mailer.default
email_canonicalizer: fos_user.util.email_canonicalizer.default
username_canonicalizer: fos_user.util.username_canonicalizer.default
user_manager: fos_user.user_manager.default
encoder:
algorithm: sha512
encode_as_base64: false
iterations: 1
template:
engine: twig
theme: FOSUserBundle::form.html.twig
group:
group_class: ~ # Required when using groups
form:
type: FOSUserBundleFormGroupFormType
handler: FOSUserBundleFormGroupHandler
name: fos_user_group_form
validation_groups: [Registration]
Configuration example
配置示例
=====================
This section provides a working configuration for the bundle and the security.
本段為Bundle和安全提供了一個可正常工作的配置。
FOSUserBundle configuration
FOSUserBundle配置
—————————
::
# app/config/config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: MyProjectMyBundleEntityUser
Security configuration
安全配置
———————-
::
# app/config/security.yml
security:
providers:
fos_userbundle:
id: fos_user.user_manager
firewalls:
main:
pattern: .*
form_login:
provider: fos_userbundle
login_path: /login
use_forward: false
check_path: /login_check
failure_path: null
logout: true
anonymous: true
access_control:
# The WDT has to be allowed to anonymous users to avoid requiring the login with the AJAX request必須允許匿名使用者訪問以避免使用AJAX請求時要求登入
# WDT必須允許匿名使用者訪問,以避免在使用AJAX請求時被要求登入
– { path: ^/_wdt/, role: IS_AUTHENTICATED_ANONYMOUSLY }
– { path: ^/_profiler/, role: IS_AUTHENTICATED_ANONYMOUSLY }
# AsseticBundle paths used when using the controller for assets
# 當為assets使用控制器時將AsseticBundle路徑
– { path: ^/js/, role: IS_AUTHENTICATED_ANONYMOUSLY }
– { path: ^/css/, role: IS_AUTHENTICATED_ANONYMOUSLY }
# URL of FOSUserBundle which need to be available to anonymous users
# FOSUserBundle的URL,需要匿名使用者可見
– { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
– { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
– { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
# Secured part of the site
# 網站安全部分
# This config requires being logged for the whole site and having the admin role for the admin part.
# 這個配置要求正在被全站記錄,並且對admin部分要求管理角色
# Change these rules to adapt them to your needs
# 改變這些角色使它們適應您的需要
– { path: ^/admin/, role: ROLE_ADMIN }
– { path: ^/.*, role: ROLE_USER }
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
Replacing some part by your own implementation
使用您自己的實現替換一些部分
==============================================
Templating
模板
———-
The template names are not configurable, however Symfony2 makes it possible
to extend a bundle by defining a template in the app/ directory.
模板名是不可配置的,然而為了擴充套件Bundle,Symfony2可以通過在app/目錄中定義模板來使之成為可能。
For example “vendor/bundles/FOS/UserBundle/Resources/views/User/new.twig“ can be
replaced inside an application by putting a file with alternative content in
“app/Resources/FOSUserBundle/views/User/new.twig“.
舉個例子,“vendor/bundles/FOS/UserBundle/Resources/views/User/new.twig“可以通過在應用程式中放置的“app/Resources/FOSUserBundle/views/User/new.twig“檔案內容所取代。
You could also create a bundle defined as child of FOSUserBundle and placing the
templates in it.
您也可以建立一個FOSUserBundle的子Bundle,並將模板放置其中。
You can use a different templating engine by configuring it but you will have to
create all the needed templates as only twig templates are provided.
通過配置您可以使用不同的模板引擎,但您必須得建立所有需要的模板,而不僅是隻提供twig模板。
Controller
控制器
———-
To overwrite a controller, create a bundle defined a child of FOSUserBundle
and create a controller with the same name in this bundle.
要覆寫一個控制器,可以建立一個FOSUserBundle的子Bundle,並在該Bundle中建立同名的控制器。
Validation
驗證
———-
The “Resources/config/validation.xml“ file contains definitions for custom
validator rules for various classes. The rules defined by FOSUserBundle are
all in a validation group so you can choose not to use them.
“Resources/config/validation.xml“檔案包含了為不同類自定義的驗證器規則。這些被FOSUserBundle定義的規則都被放置在一個驗證組中,因此您可以選擇不使用它們。
Emails
電子郵件
——
The default mailer relies on Swiftmailer to send the mails of the bundle.
If you want to use another mailer in your project you can change it by defining
your own service implementing “FOSUserBundleMailerMailerInterface“ and
setting its id in the configuration
預設郵件系統依賴於Swiftmailer來傳送Bundle的郵件。如果您想在您的專案中使用其它的郵件系統,您可以通過定義您自己的服務來改變它。該服務必須要實現 “FOSUserBundleMailerMailerInterface“介面,並在配置中設定它的ID。
::
fos_user:
# …
service:
mailer: custom_mailer_id
This bundle comes with two mailer implementations.
該Bundle有兩個郵件系統實現。
– `fos_user.mailer.default` is the default implementation, and uses swiftmailer to send emails.
– `fos_user.mailer.default` 是預設實現,它使用swiftmailer來傳送郵件。
– `fos_user.mailer.noop` does nothing and can be used if your project does not depend on swiftmailer.
– `fos_user.mailer.noop` 不做任何事,如果您的專案不使用swiftmailer,可以使用它。
Canonicalization
規範
—————-
“Canonicalizer“ services are used to canonicalize the username and the email
fields for database storage. By default, username and email fields are
canonicalized in the same manner using “mb_convert_case()“. You may configure
your own class for each field provided it implements
“FOSUserBundleUtilCanonicalizerInterface“.
“Canonicalizer“ 服務為資料庫儲存規範使用者名稱和郵件欄位。預設情況下,使用者名稱和郵件欄位同樣都是使用“mb_convert_case()“來進行規範的。您也許想為每個欄位都配置您自己的類,這可以通過實現“FOSUserBundleUtilCanonicalizerInterface“介面來提供。
.. note
.. 注意
::
If you do not have the mbstring extension installed you will need to
define your own “canonicalizer“.
如果您沒有安裝mbstring擴充套件,您需要定義您自己的“canonicalizer“
本文轉自 firehare 51CTO部落格,原文連結:http://blog.51cto.com/firehare/595319,如需轉載請自行聯絡原作者
相關文章
- prerender-spa-plugin 預渲染外掛的使用說明Plugin
- IDEA Maven Helper 外掛的安裝與使用說明IdeaMaven
- Flutter外掛之webview_flutter簡要使用說明FlutterWebView
- jenkins構建後操作post build tasks外掛的使用說明JenkinsUI
- DataTables表格外掛使用說明
- 說說如何使用 vue-router 外掛Vue
- HtmlWebpackPlugin外掛和HtmlWebpackInlineSourcePlugin外掛的使用HTMLWebPlugininline
- fastadmin的【外掛管理】外掛使用教程AST
- oradebug的使用說明
- 使用說明
- burp外掛的使用
- Headshot外掛如何使用?Headshot外掛使用教程
- FreeSql 使用說明SQL
- postman 使用說明Postman
- QLExpress使用說明Express
- WebApiClientCore使用說明WebAPIclient
- Jupiter 使用說明
- certbot 使用說明
- cmake使用說明
- ApplicationContextAware使用說明APPContext
- DataLakeAnalytics中OSSLOCATION的使用說明
- 關於 Jupyter 的使用說明
- apisix~限流外掛的使用API
- [IDEA] chapter_reader - idea看小說外掛 idea閱讀外掛 idea摸魚外掛IdeaAPT
- VSCode 中 Markdown Preview Enhanced 外掛利用 Chrome (Puppeteer) 匯出 PDF 檔案使用說明與問題解決VSCodeViewChrome
- axios使用說明書iOS
- wc 命令使用說明
- oracle orapwd使用說明Oracle
- JPA EntityManager使用說明
- markdown使用小說明
- videojs外掛使用IDEJS
- Head 外掛使用
- [-Flutter外掛篇 1-] 從自定義外掛開始說起Flutter
- 【曹工雜談】說說Maven框架和外掛的契約Maven框架
- Webots和ROS的使用說明(譯)WebROS
- Spring的@Qualifier註解使用說明Spring
- 我使用的 Sublime Text 外掛
- mybatisPlus分頁外掛的使用MyBatis
- Flutter 外掛的建立及使用Flutter