From 922f5dc0bb701e10a78ecb15ef48f59af95ec11b Mon Sep 17 00:00:00 2001 From: tattali Date: Tue, 18 Dec 2018 11:20:26 +0100 Subject: [PATCH 1/7] Update index.rst --- Resources/doc/index.rst | 248 +++++++++++++++++++++++----------------- 1 file changed, 140 insertions(+), 108 deletions(-) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index a334051030..f2363a279a 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -15,36 +15,60 @@ For a video tutorial, check out `FOSUserBundle FTW`_ by KnpUniversity. Prerequisites ------------- -This version of the bundle requires Symfony 2.8+. If you are using an older -Symfony version, please use the 1.3.x releases of the bundle. +This version of the documentation requires Symfony flex. If you are using an older +Symfony version, please use the 2.8+ or 1.3.x releases of the documentation. Translations ~~~~~~~~~~~~ If you wish to use default texts provided in this bundle, you have to make -sure you have translator enabled in your config. +sure you have translator installed in your project. -.. code-block:: yaml +.. code-block:: bash + + $ composer require symfony/translation + +For more information about translations, check `translator component documentation`_. + +Mailer +~~~~~~ + +This bundle requires a mailer to send email provided in this bundle, you have to make +sure you have a mailer intalled in your project. + +.. code-block:: bash + + $ composer require symfony/swiftmailer-bundle + +For more information about email, check `swiftmailer component documentation`_. + +Storage +~~~~~~~ + +This bundle requires a storage to persist some ``User`` class to a database. +If you wish to use one of the doctrine variants (Doctrine ORM, MongoDB ODM, +or CouchDB ODM). You also may use a custom storage. - # app/config/config.yml +.. code-block:: bash - framework: - translator: ~ + $ composer require symfony/orm-pack + $ composer require doctrine/mongodb-odm-bundle + $ composer require doctrine/couchdb-odm-bundle -For more information about translations, check `Symfony documentation`_. +For more information about custom storage, check `custom_storage_layer`_. Installation ------------ -Installation is a quick (I promise!) 7 step process: +Installation is a quick (I promise!) 6 step process: 1. Download FOSUserBundle using composer -2. Enable the Bundle +2. Configure the FOSUserBundle 3. Create your User class -4. Configure your application's security.yml -5. Configure the FOSUserBundle -6. Import FOSUserBundle routing -7. Update your database schema +4. Configure your application's security.yaml +5. Import FOSUserBundle routing +6. Update your database schema + Step 1: Download FOSUserBundle using composer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -53,27 +77,82 @@ Require the bundle with composer: .. code-block:: bash - $ composer require friendsofsymfony/user-bundle "~2.0" + $ composer require friendsofsymfony/user-bundle "~2.1" Composer will install the bundle to your project's ``vendor/friendsofsymfony/user-bundle`` directory. -If you encounter installation errors pointing at a lack of configuration parameters, such as ``The child node "db_driver" at path "fos_user" must be configured``, you should complete the configuration in Step 5 first and then re-run this step. +If you encounter installation errors pointing at a lack of configuration parameters, +such as ``The child node "db_driver" at path "fos_user" must be configured``, +you should complete the configuration in Step 2 first and then re-run this step. -Step 2: Enable the bundle -~~~~~~~~~~~~~~~~~~~~~~~~~ +The bundle enabling should be done automatically in the ``config/bundles.php`` by the auto generated recipe. -Enable the bundle in the kernel:: - + + + + + twig + + + + + + +Only four configuration's nodes are required to use the bundle: + +* The type of datastore you are using (``orm``, ``mongodb`` or ``couchdb``). +* The firewall name which you configured in 5. +* The fully qualified class name (FQCN) of the ``User`` class which you created in Step 3. +* The default email address to use when the bundle send a registration confirmation to the user. + +You should add the following environnements variables to your ``.env`` file + +.. code-block:: env + + MAILER_SENDER_ADDRESS=johndoe@example.com + MAILER_SENDER_NAME="John Doe" + +.. note:: + + FOSUserBundle uses a compiler pass to register mappings for the base + User and Group model classes with the object manager that you configured + it to use. (Unless specified explicitly, this is the default manager + of your doctrine configuration.) - public function registerBundles() - { - $bundles = array( - // ... - new FOS\UserBundle\FOSUserBundle(), - // ... - ); - } Step 3: Create your User class ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -101,7 +180,7 @@ or CouchDB ODM). .. note:: - The doc uses a bundle named ``AppBundle`` according to the Symfony best + The doc uses a bundle named ``App`` according to the Symfony best practices. However, you can of course place your user class in the bundle you want. @@ -123,9 +202,9 @@ start: .. code-block:: php-annotations - + - + @@ -189,9 +268,9 @@ class should live in the ``Document`` namespace of your bundle and look like this to start:: - - - -Only four configuration's nodes are required to use the bundle: - -* The type of datastore you are using (``orm``, ``mongodb`` or ``couchdb``). -* The firewall name which you configured in Step 4. -* The fully qualified class name (FQCN) of the ``User`` class which you created in Step 3. -* The default email address to use when the bundle send a registration confirmation to the user. - -.. note:: - - FOSUserBundle uses a compiler pass to register mappings for the base - User and Group model classes with the object manager that you configured - it to use. (Unless specified explicitly, this is the default manager - of your doctrine configuration.) - -Step 6: Import FOSUserBundle routing files +Step 5: Import FOSUserBundle routing files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Now that you have activated and configured the bundle, all that is left to do is @@ -384,36 +416,40 @@ import the FOSUserBundle routing files. By importing the routing files you will have ready made pages for things such as logging in, creating users, etc. +You should create the ``config/routes/fos_user.yaml`` if needed. + .. configuration-block:: .. code-block:: yaml - # app/config/routing.yml + # config/routes/fos_user.yaml fos_user: resource: "@FOSUserBundle/Resources/config/routing/all.xml" .. code-block:: xml - - + + .. note:: In order to use the built-in email functionality (confirmation of the account, resetting of the password), you must activate and configure the SwiftmailerBundle. -Step 7: Update your database schema + +Step 6: Update your database schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Now that the bundle is configured, the last thing you need to do is update your database schema because you have added a new entity, the ``User`` class which you -created in Step 4. +created in Step 3. For ORM run the following command. .. code-block:: bash - $ php bin/console doctrine:schema:update --force + $ php bin/console doctrine:migration:diff + $ php bin/console doctrine:migration:migrate --no-interaction For MongoDB users you can run the following command to create the indexes. @@ -421,12 +457,7 @@ For MongoDB users you can run the following command to create the indexes. $ php bin/console doctrine:mongodb:schema:create --index -.. note:: - - If you use the Symfony 2.x structure in your project, use ``app/console`` - instead of ``bin/console`` in the commands. - -You now can log in at ``http://app.com/app_dev.php/login``! +You now can log in at ``http://localhost:8000/login``! Next Steps ~~~~~~~~~~ @@ -457,7 +488,8 @@ The following documents are available: configuration_reference adding_invitation_registration -.. _security component documentation: https://symfony.com/doc/current/book/security.html -.. _Symfony documentation: https://symfony.com/doc/current/book/translation.html +.. _security component documentation: https://symfony.com/doc/current/security.html +.. _translator component documentation: https://symfony.com/doc/current/translation.html +.. _swiftmailer documentation: https://symfony.com/doc/current/email.html .. _TypehintableBehavior: https://github.com/willdurand/TypehintableBehavior .. _FOSUserBundle FTW: https://knpuniversity.com/screencast/fosuserbundle From de9b3a860ed2d165a78f7a19b67511c0a8802149 Mon Sep 17 00:00:00 2001 From: tattali Date: Tue, 18 Dec 2018 11:34:22 +0100 Subject: [PATCH 2/7] Update index.rst --- Resources/doc/index.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index f2363a279a..125c65c0a1 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -40,7 +40,7 @@ sure you have a mailer intalled in your project. $ composer require symfony/swiftmailer-bundle -For more information about email, check `swiftmailer component documentation`_. +For more information about email, check `swiftmailer documentation`_. Storage ~~~~~~~ @@ -54,8 +54,7 @@ or CouchDB ODM). You also may use a custom storage. $ composer require symfony/orm-pack $ composer require doctrine/mongodb-odm-bundle $ composer require doctrine/couchdb-odm-bundle - -For more information about custom storage, check `custom_storage_layer`_. + Installation ------------ From be822bcc7a19d5b58792290a243a19c5e01a6f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Attali?= Date: Tue, 29 Jan 2019 16:58:21 +0100 Subject: [PATCH 3/7] travis From 4dcdd418cb9015fe9458e52ddf2c1a0b93b87c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Attali?= Date: Wed, 30 Jan 2019 12:27:01 +0100 Subject: [PATCH 4/7] travis From dc76d4c952d5767bbaf1d1bdf93f41f83e299a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Attali?= Date: Wed, 30 Jan 2019 13:40:36 +0100 Subject: [PATCH 5/7] add link to 2.0.x doc in readme --- README.md | 2 ++ Resources/doc/index.rst | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3371ba2481..38db006d52 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ in this bundle, and available on symfony.com: [Read the Documentation for master](https://symfony.com/doc/master/bundles/FOSUserBundle/index.html) +[Read the Documentation for 2.0.x](https://symfony.com/doc/2.0.x/bundles/FOSUserBundle/index.html) + [Read the Documentation for 1.3.x](https://symfony.com/doc/1.3.x/bundles/FOSUserBundle/index.html) Installation diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 125c65c0a1..ea7de06204 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -16,7 +16,7 @@ Prerequisites ------------- This version of the documentation requires Symfony flex. If you are using an older -Symfony version, please use the 2.8+ or 1.3.x releases of the documentation. +Symfony version, please use the 2.0.x or 1.3.x releases of the documentation. Translations ~~~~~~~~~~~~ @@ -54,7 +54,7 @@ or CouchDB ODM). You also may use a custom storage. $ composer require symfony/orm-pack $ composer require doctrine/mongodb-odm-bundle $ composer require doctrine/couchdb-odm-bundle - + Installation ------------ @@ -79,8 +79,8 @@ Require the bundle with composer: $ composer require friendsofsymfony/user-bundle "~2.1" Composer will install the bundle to your project's ``vendor/friendsofsymfony/user-bundle`` directory. -If you encounter installation errors pointing at a lack of configuration parameters, -such as ``The child node "db_driver" at path "fos_user" must be configured``, +If you encounter installation errors pointing at a lack of configuration parameters, +such as ``The child node "db_driver" at path "fos_user" must be configured``, you should complete the configuration in Step 2 first and then re-run this step. The bundle enabling should be done automatically in the ``config/bundles.php`` by the auto generated recipe. @@ -91,7 +91,7 @@ Step 2: Configure the FOSUserBundle The next step is to configure the bundle to work with the specific needs of your application. -Add the following configuration to your ``config/packages/fos_user.yaml`` file +Add the following configuration to your ``config/packages/fos_user.yaml`` file according to which type of datastore you are using. You should create the file if needed. .. configuration-block:: @@ -138,7 +138,7 @@ Only four configuration's nodes are required to use the bundle: * The fully qualified class name (FQCN) of the ``User`` class which you created in Step 3. * The default email address to use when the bundle send a registration confirmation to the user. -You should add the following environnements variables to your ``.env`` file +You should add the following environnements variables to your ``.env`` file .. code-block:: env @@ -328,7 +328,7 @@ like this to start:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In order for Symfony's security component to use the FOSUserBundle, you must -tell it to do so in the ``config/packages/security.yaml`` file. +tell it to do so in the ``config/packages/security.yaml`` file. The ``security.yaml`` file is where the basic security configuration for your application is contained. Below is a minimal example of the configuration necessary to use the FOSUserBundle From 78bc1eee57e7fb01a6078ae283de2fbc10c1ba60 Mon Sep 17 00:00:00 2001 From: tattali Date: Tue, 19 Feb 2019 23:36:28 +0100 Subject: [PATCH 6/7] use security.user_checker --- Resources/doc/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index ea7de06204..628b61c832 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -352,7 +352,7 @@ in your application: firewalls: main: pattern: ^/ - user_checker: fos_user.user_checker + user_checker: security.user_checker form_login: provider: fos_userbundle csrf_token_generator: security.csrf.token_manager From 85098a4ce83afb1a3a4afa363f3d1c59961a94fa Mon Sep 17 00:00:00 2001 From: tattali Date: Wed, 20 Feb 2019 14:41:45 +0100 Subject: [PATCH 7/7] remove the translation bundle section --- Resources/doc/index.rst | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 628b61c832..00a3d8436a 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -18,18 +18,6 @@ Prerequisites This version of the documentation requires Symfony flex. If you are using an older Symfony version, please use the 2.0.x or 1.3.x releases of the documentation. -Translations -~~~~~~~~~~~~ - -If you wish to use default texts provided in this bundle, you have to make -sure you have translator installed in your project. - -.. code-block:: bash - - $ composer require symfony/translation - -For more information about translations, check `translator component documentation`_. - Mailer ~~~~~~