From 0127bd24ccd3face99a94de0aa96f96deac7a47e Mon Sep 17 00:00:00 2001 From: bfgasparin Date: Mon, 7 Apr 2014 19:28:54 -0300 Subject: [PATCH 01/18] Updated event_listener.rst Updated event_listener.rst to use the new KernelEvent::isMasterRequest method --- cookbook/service_container/event_listener.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/service_container/event_listener.rst b/cookbook/service_container/event_listener.rst index 0676ca4479a..0aa7da76fd5 100644 --- a/cookbook/service_container/event_listener.rst +++ b/cookbook/service_container/event_listener.rst @@ -115,7 +115,7 @@ done as follow:: { public function onKernelRequest(GetResponseEvent $event) { - if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) { + if (false === $event->isMasterRequest()) { // don't do anything if it's not the master request return; } From 8e8b8a00d04222aafe6e27c394998673ba2194ac Mon Sep 17 00:00:00 2001 From: bfgasparin Date: Tue, 8 Apr 2014 17:15:42 -0300 Subject: [PATCH 02/18] Added Versionadded directive to event_listener.rst Added missing Versionadded directive to event_listener.rst --- cookbook/service_container/event_listener.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cookbook/service_container/event_listener.rst b/cookbook/service_container/event_listener.rst index 0aa7da76fd5..c37edc0a0ce 100644 --- a/cookbook/service_container/event_listener.rst +++ b/cookbook/service_container/event_listener.rst @@ -124,6 +124,10 @@ done as follow:: } } +.. versionadded:: 2.4 + The ``isMasterRequest()`` method was introduced in Symfony 2.4. + Prior, the ``getRequestType()`` method must be used. + .. tip:: Two types of request are available in the :class:`Symfony\\Component\\HttpKernel\\HttpKernelInterface` From a6b17a00297b1315604459883429f9953ce708c4 Mon Sep 17 00:00:00 2001 From: Bruno Ferme Gasparin Date: Thu, 10 Apr 2014 02:25:04 -0300 Subject: [PATCH 03/18] Added KernelEvent::isMasterRequest method reference --- book/internals.rst | 13 ++++++++++--- components/http_kernel/introduction.rst | 10 +++++++--- cookbook/service_container/event_listener.rst | 10 +++++----- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/book/internals.rst b/book/internals.rst index cf204094287..829120a3047 100644 --- a/book/internals.rst +++ b/book/internals.rst @@ -208,6 +208,10 @@ processing must only occur on the master request). Events ~~~~~~ +.. versionadded:: 2.4 + The ``isMasterRequest()`` method was introduced in Symfony 2.4. + Prior, the ``getRequestType()`` method must be used. + Each event thrown by the Kernel is a subclass of :class:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent`. This means that each event has access to the same basic information: @@ -216,22 +220,25 @@ each event has access to the same basic information: - returns the *type* of the request (``HttpKernelInterface::MASTER_REQUEST`` or ``HttpKernelInterface::SUB_REQUEST``); +* :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::isMasterRequest` + - checks if it is a master request; + * :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::getKernel` - returns the Kernel handling the request; * :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::getRequest` - returns the current ``Request`` being handled. -``getRequestType()`` +``IsMasterRequest()`` .................... -The ``getRequestType()`` method allows listeners to know the type of the +The ``isMasterRequest()`` method allows listeners to check the type of the request. For instance, if a listener must only be active for master requests, add the following code at the beginning of your listener method:: use Symfony\Component\HttpKernel\HttpKernelInterface; - if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + if (!$event->isMasterRequest()) { // return immediately return; } diff --git a/components/http_kernel/introduction.rst b/components/http_kernel/introduction.rst index 5ab8e5c729b..d486630fc3b 100644 --- a/components/http_kernel/introduction.rst +++ b/components/http_kernel/introduction.rst @@ -665,12 +665,16 @@ argument as follows:: $response = $kernel->handle($request, HttpKernelInterface::SUB_REQUEST); // do something with this response +.. versionadded:: 2.4 + The ``isMasterRequest()`` method was introduced in Symfony 2.4. + Prior, the ``getRequestType()`` method must be used. + This creates another full request-response cycle where this new ``Request`` is transformed into a ``Response``. The only difference internally is that some listeners (e.g. security) may only act upon the master request. Each listener is passed some sub-class of :class:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent`, -whose :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::getRequestType` -can be used to figure out if the current request is a "master" or "sub" request. +whose :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::isMasterRequest` +can be used to check if the current request is a "master" or "sub" request. For example, a listener that only needs to act on the master request may look like this:: @@ -680,7 +684,7 @@ look like this:: public function onKernelRequest(GetResponseEvent $event) { - if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { + if (!$event->isMasterRequest()) { return; } diff --git a/cookbook/service_container/event_listener.rst b/cookbook/service_container/event_listener.rst index c37edc0a0ce..4e61fdbff92 100644 --- a/cookbook/service_container/event_listener.rst +++ b/cookbook/service_container/event_listener.rst @@ -100,6 +100,10 @@ using a special "tag": Request events, checking types ------------------------------ +.. versionadded:: 2.4 + The ``isMasterRequest()`` method was introduced in Symfony 2.4. + Prior, the ``getRequestType()`` method must be used. + A single page can make several requests (one master request, and then multiple sub-requests), which is why when working with the ``KernelEvents::REQUEST`` event, you might need to check the type of the request. This can be easily @@ -115,7 +119,7 @@ done as follow:: { public function onKernelRequest(GetResponseEvent $event) { - if (false === $event->isMasterRequest()) { + if (!$event->isMasterRequest()) { // don't do anything if it's not the master request return; } @@ -124,10 +128,6 @@ done as follow:: } } -.. versionadded:: 2.4 - The ``isMasterRequest()`` method was introduced in Symfony 2.4. - Prior, the ``getRequestType()`` method must be used. - .. tip:: Two types of request are available in the :class:`Symfony\\Component\\HttpKernel\\HttpKernelInterface` From 4fc3b6acd768a9c54249b10fa7746fb80b69b506 Mon Sep 17 00:00:00 2001 From: bfgasparin Date: Thu, 10 Apr 2014 17:22:26 -0300 Subject: [PATCH 04/18] Fixed internals.rst syntax --- book/internals.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/internals.rst b/book/internals.rst index 829120a3047..250242b7277 100644 --- a/book/internals.rst +++ b/book/internals.rst @@ -229,8 +229,8 @@ each event has access to the same basic information: * :method:`Symfony\\Component\\HttpKernel\\Event\\KernelEvent::getRequest` - returns the current ``Request`` being handled. -``IsMasterRequest()`` -.................... +``isMasterRequest()`` +..................... The ``isMasterRequest()`` method allows listeners to check the type of the request. For instance, if a listener must only be active for master requests, From 011e0f0d45d426456ffe79a533a529a0e4ce010e Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Sat, 3 May 2014 19:12:31 +0200 Subject: [PATCH 05/18] Update .gitignore example As confirmed by WouterJ on Stack Overflow [1], the example .gitignore file [2] is not up-to-date. This commit updates the documentation to reflect the current state of the .gitignore file that is included in the Symfony Standard Edition distribution [3]. [1] http://stackoverflow.com/q/23437768/1001110 [2] http://symfony.com/doc/current/cookbook/workflow/new_project_git.html#initial-project-setup [3] https://github.com/symfony/symfony-standard/blob/master/.gitignore --- cookbook/workflow/new_project_git.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index f0403af21a1..8d81ff42da0 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -32,11 +32,16 @@ git repository: .. code-block:: text /web/bundles/ - /app/bootstrap* + /app/bootstrap.php.cache /app/cache/* + /app/config/parameters.yml /app/logs/* + !app/cache/.gitkeep + !app/logs/.gitkeep + /build/ /vendor/ - /app/config/parameters.yml + /bin/ + /composer.phar .. tip:: From 34d61eb4e03399fe1b8c1632d0d439386c6a4b76 Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Sun, 4 May 2014 15:54:50 +0200 Subject: [PATCH 06/18] Update the complete 'Initial Project Setup' paragraph As proposed by WouterJ in https://github.com/symfony/symfony-docs/pull/3827 this commit rewrites the 'Initial Project Setup' paragraph. The documentation now describes the recommended way of creating a new Symfony2 project, using Composer to download the Standard Distribution + vendors (instead of downloading the zipped version). As the Standard Edition already contains a .gitignore, the example is replaced by a link to the one stored at GitHub. The article also explains which files are excluded by .gitignore. The last step (downloading vendor libraries using Composer) is removed as this is now covered by step 1. --- cookbook/workflow/new_project_git.rst | 49 ++++++++++++++------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index 8d81ff42da0..03e94345f21 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -20,28 +20,30 @@ Initial Project Setup To get started, you'll need to download Symfony and initialize your local git repository: -1. Download the `Symfony2 Standard Edition`_ without vendors. +1. Download the `Symfony2 Standard Edition`_ using Composer: -2. Unzip/untar the distribution. It will create a folder called Symfony with - your new project structure, config files, etc. Rename it to whatever you like. + .. code-block:: bash + + $ php composer.phar create-project symfony/framework-standard-edition path/ 2.4.4 -3. Create a new file called ``.gitignore`` at the root of your new project - (e.g. next to the ``composer.json`` file) and paste the following into it. Files - matching these patterns will be ignored by Git: + Composer will now download the Standard Distribution along with all of the + required vendor libraries. For more information about downloading Symfony using + Composer, see `Installing Symfony using Composer`_. - .. code-block:: text +2. Your project folder will now contain files of the Symfony framework, as well + as files and folders for vendor libraries. You'll want to store your project + files in Git, but not the dependencies, since they will be managed by Composer. + You'll also want to keep your ``parameters.yml`` out of your repository as it will + contain sensitive information, such as database credentials. Furthermore, + files that are automatically created by Symfony (such as logs, caches, and dumped + assets) should be excluded as well. - /web/bundles/ - /app/bootstrap.php.cache - /app/cache/* - /app/config/parameters.yml - /app/logs/* - !app/cache/.gitkeep - !app/logs/.gitkeep - /build/ - /vendor/ - /bin/ - /composer.phar + To help you keep these files out of your repository, Symfony comes with a file + called ``.gitignore``. It contains a list of files and folders that Git will + ignore. + + The contents of the ``.gitignore`` file that comes with the Standard Distribution + can be found in the `GitHub repository`_. .. tip:: @@ -49,27 +51,24 @@ git repository: in which case, you can find more information here: `Github .gitignore`_ This way you can exclude files/folders often used by your IDE for all of your projects. -4. Initialize your Git repository: +3. Initialize your Git repository: .. code-block:: bash $ git init -5. Add all of the initial files to Git: +4. Add all of the initial files to Git: .. code-block:: bash $ git add . -6. Create an initial commit with your started project: +5. Create an initial commit with your started project: .. code-block:: bash $ git commit -m "Initial commit" -7. Finally, download all of the third-party vendor libraries by - executing Composer. For details, see :ref:`installation-updating-vendors`. - At this point, you have a fully-functional Symfony2 project that's correctly committed to Git. You can immediately begin development, committing the new changes to your Git repository. @@ -116,6 +115,8 @@ manage this is `Gitolite`_. .. _`Git`: http://git-scm.com/ .. _`Symfony2 Standard Edition`: http://symfony.com/download +.. _`Installing Symfony using Composer`: http://symfony.com/doc/current/book/installation.html#option-1-composer +.. _`GitHub repository`: https://github.com/symfony/symfony-standard/blob/master/.gitignore .. _`git submodules`: http://git-scm.com/book/en/Git-Tools-Submodules .. _`GitHub`: https://github.com/ .. _`barebones repository`: http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository From 6a196289f311c4f0b64025af27e906193a4776f6 Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Mon, 5 May 2014 20:22:09 +0200 Subject: [PATCH 07/18] Indent the tip to be on the same level as the list item --- cookbook/workflow/new_project_git.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index 03e94345f21..96e051abb9a 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -45,11 +45,11 @@ git repository: The contents of the ``.gitignore`` file that comes with the Standard Distribution can be found in the `GitHub repository`_. -.. tip:: + .. tip:: - You may also want to create a .gitignore file that can be used system-wide, - in which case, you can find more information here: `Github .gitignore`_ - This way you can exclude files/folders often used by your IDE for all of your projects. + You may also want to create a .gitignore file that can be used system-wide, + in which case, you can find more information here: `Github .gitignore`_ + This way you can exclude files/folders often used by your IDE for all of your projects. 3. Initialize your Git repository: From 311f14bf587db62821a42b7c3f974a034821b472 Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Mon, 5 May 2014 20:23:30 +0200 Subject: [PATCH 08/18] Replace numbered list items with # ...so we don't have to renumber them every time we remove/add a new item. --- cookbook/workflow/new_project_git.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index 96e051abb9a..e7c59a30eb5 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -20,7 +20,7 @@ Initial Project Setup To get started, you'll need to download Symfony and initialize your local git repository: -1. Download the `Symfony2 Standard Edition`_ using Composer: +#. Download the `Symfony2 Standard Edition`_ using Composer: .. code-block:: bash @@ -30,7 +30,7 @@ git repository: required vendor libraries. For more information about downloading Symfony using Composer, see `Installing Symfony using Composer`_. -2. Your project folder will now contain files of the Symfony framework, as well +#. Your project folder will now contain files of the Symfony framework, as well as files and folders for vendor libraries. You'll want to store your project files in Git, but not the dependencies, since they will be managed by Composer. You'll also want to keep your ``parameters.yml`` out of your repository as it will @@ -51,19 +51,19 @@ git repository: in which case, you can find more information here: `Github .gitignore`_ This way you can exclude files/folders often used by your IDE for all of your projects. -3. Initialize your Git repository: +#. Initialize your Git repository: .. code-block:: bash $ git init -4. Add all of the initial files to Git: +#. Add all of the initial files to Git: .. code-block:: bash $ git add . -5. Create an initial commit with your started project: +#. Create an initial commit with your started project: .. code-block:: bash From 32cee81f3acf393a3324a4917c8eac49026c70d4 Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Tue, 13 May 2014 14:08:22 +0200 Subject: [PATCH 09/18] Small change in the wording ...as suggested by weaverryan. --- cookbook/workflow/new_project_git.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index e7c59a30eb5..1bf95850a85 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -30,7 +30,7 @@ git repository: required vendor libraries. For more information about downloading Symfony using Composer, see `Installing Symfony using Composer`_. -#. Your project folder will now contain files of the Symfony framework, as well +#. Your project folder will now contain files for your new project, as well as files and folders for vendor libraries. You'll want to store your project files in Git, but not the dependencies, since they will be managed by Composer. You'll also want to keep your ``parameters.yml`` out of your repository as it will From 083c1f52a953920f85439ff622b1e0ee9d4a68e3 Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Fri, 16 May 2014 08:52:04 +0200 Subject: [PATCH 10/18] Replace static version constraint (2.4.4) ...with a smarter one. Using Composer's tilde operator (~), also known as the next significant release constraint, we instruct composer to use at least Symfony 2.3, but not 3.0 or higher. --- cookbook/workflow/new_project_git.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index 1bf95850a85..16c2f21da31 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -24,7 +24,7 @@ git repository: .. code-block:: bash - $ php composer.phar create-project symfony/framework-standard-edition path/ 2.4.4 + $ php composer.phar create-project symfony/framework-standard-edition path/ ~2.3 Composer will now download the Standard Distribution along with all of the required vendor libraries. For more information about downloading Symfony using From d9f72f95087e6bdcbd06ce2f4613acc531e6dfe5 Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Fri, 16 May 2014 09:17:15 +0200 Subject: [PATCH 11/18] Some refactoring of the article Shorten the 2nd list item a bit, and move it into a 'Tip' seems to make more sense. --- cookbook/workflow/new_project_git.rst | 39 ++++++++++++--------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index 16c2f21da31..259df03dc9f 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -30,27 +30,6 @@ git repository: required vendor libraries. For more information about downloading Symfony using Composer, see `Installing Symfony using Composer`_. -#. Your project folder will now contain files for your new project, as well - as files and folders for vendor libraries. You'll want to store your project - files in Git, but not the dependencies, since they will be managed by Composer. - You'll also want to keep your ``parameters.yml`` out of your repository as it will - contain sensitive information, such as database credentials. Furthermore, - files that are automatically created by Symfony (such as logs, caches, and dumped - assets) should be excluded as well. - - To help you keep these files out of your repository, Symfony comes with a file - called ``.gitignore``. It contains a list of files and folders that Git will - ignore. - - The contents of the ``.gitignore`` file that comes with the Standard Distribution - can be found in the `GitHub repository`_. - - .. tip:: - - You may also want to create a .gitignore file that can be used system-wide, - in which case, you can find more information here: `Github .gitignore`_ - This way you can exclude files/folders often used by your IDE for all of your projects. - #. Initialize your Git repository: .. code-block:: bash @@ -63,6 +42,23 @@ git repository: $ git add . + .. tip:: + + As you might have noticed, not all files that were downloaded by Composer in step 1, + have been staged for commit by Git. Certain files and folders, such as the project's + dependencies (which are managed by Composer), ``parameters.yml`` (which contains sensitive + information such as database credentials) and log-, cache- and asset files (which are + created automatically by your project), should not be committed in Git. To help you prevent + committing those files and folders by accident, the Standard Distribution comes with a + file called ``.gitignore``, which contains a list of files and folders that Git should + ignore. + + .. tip:: + + You may also want to create a .gitignore file that can be used system-wide, + in which case, you can find more information here: `Github .gitignore`_ + This way you can exclude files/folders often used by your IDE for all of your projects. + #. Create an initial commit with your started project: .. code-block:: bash @@ -116,7 +112,6 @@ manage this is `Gitolite`_. .. _`Git`: http://git-scm.com/ .. _`Symfony2 Standard Edition`: http://symfony.com/download .. _`Installing Symfony using Composer`: http://symfony.com/doc/current/book/installation.html#option-1-composer -.. _`GitHub repository`: https://github.com/symfony/symfony-standard/blob/master/.gitignore .. _`git submodules`: http://git-scm.com/book/en/Git-Tools-Submodules .. _`GitHub`: https://github.com/ .. _`barebones repository`: http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository From 6fd5e5281effcf2579d9db0afe0fdb39b06bd555 Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Fri, 16 May 2014 09:22:57 +0200 Subject: [PATCH 12/18] Small improvement --- cookbook/workflow/new_project_git.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index 259df03dc9f..d41c50e781f 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -47,7 +47,7 @@ git repository: As you might have noticed, not all files that were downloaded by Composer in step 1, have been staged for commit by Git. Certain files and folders, such as the project's dependencies (which are managed by Composer), ``parameters.yml`` (which contains sensitive - information such as database credentials) and log-, cache- and asset files (which are + information such as database credentials), log- and cache files and dumped assets (which are created automatically by your project), should not be committed in Git. To help you prevent committing those files and folders by accident, the Standard Distribution comes with a file called ``.gitignore``, which contains a list of files and folders that Git should From 1baf7e0492d2de188cc53fd9541db09ed5c89e5f Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Mon, 19 May 2014 10:51:52 +0200 Subject: [PATCH 13/18] Remove dash --- cookbook/workflow/new_project_git.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index d41c50e781f..a6147874d2b 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -47,7 +47,7 @@ git repository: As you might have noticed, not all files that were downloaded by Composer in step 1, have been staged for commit by Git. Certain files and folders, such as the project's dependencies (which are managed by Composer), ``parameters.yml`` (which contains sensitive - information such as database credentials), log- and cache files and dumped assets (which are + information such as database credentials), log and cache files and dumped assets (which are created automatically by your project), should not be committed in Git. To help you prevent committing those files and folders by accident, the Standard Distribution comes with a file called ``.gitignore``, which contains a list of files and folders that Git should From 3f3d88659422c718ec41c158be6a0fa81c728ca2 Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Mon, 19 May 2014 10:53:25 +0200 Subject: [PATCH 14/18] Update the tip about the global .gitignore --- cookbook/workflow/new_project_git.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cookbook/workflow/new_project_git.rst b/cookbook/workflow/new_project_git.rst index a6147874d2b..8baf116d60f 100644 --- a/cookbook/workflow/new_project_git.rst +++ b/cookbook/workflow/new_project_git.rst @@ -55,9 +55,9 @@ git repository: .. tip:: - You may also want to create a .gitignore file that can be used system-wide, - in which case, you can find more information here: `Github .gitignore`_ - This way you can exclude files/folders often used by your IDE for all of your projects. + You may also want to create a ``.gitignore`` file that can be used system-wide. + This allows you to exclude files/folders for all your projects that are created by + your IDE or operating system. For details, see `Github .gitignore`_. #. Create an initial commit with your started project: From 66d60d217e88dff8d53bad319e144db5b514eb90 Mon Sep 17 00:00:00 2001 From: fatmuemoo Date: Mon, 2 Dec 2013 13:17:41 -0500 Subject: [PATCH 15/18] Update routing.rst Added a note to provide extra guidance when naming routes --- book/routing.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/book/routing.rst b/book/routing.rst index 44024702f67..6cba60a1532 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -68,6 +68,13 @@ The route is simple: return $collection; +.. note:: + + When defining routes, the key (e.g. ``blog_show``) is meaningless. + Just be sure that it's unique so no other lines override it. In most cases, a + vendorname_shortbundlename_controllername_actionname pattern + (e.g. ``acme_blog_show``) is appropriate. + .. versionadded:: 2.2 The ``path`` option was introduced in Symfony 2.2, ``pattern`` is used in older versions. From 90e654b73e58d650f9148d2fde26d1043abf90bb Mon Sep 17 00:00:00 2001 From: WouterJ Date: Wed, 21 May 2014 10:56:28 +0200 Subject: [PATCH 16/18] Applied comments --- book/routing.rst | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/book/routing.rst b/book/routing.rst index 6cba60a1532..3d05d462d6a 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -68,13 +68,6 @@ The route is simple: return $collection; -.. note:: - - When defining routes, the key (e.g. ``blog_show``) is meaningless. - Just be sure that it's unique so no other lines override it. In most cases, a - vendorname_shortbundlename_controllername_actionname pattern - (e.g. ``acme_blog_show``) is appropriate. - .. versionadded:: 2.2 The ``path`` option was introduced in Symfony 2.2, ``pattern`` is used in older versions. @@ -82,7 +75,9 @@ The route is simple: The path defined by the ``blog_show`` route acts like ``/blog/*`` where the wildcard is given the name ``slug``. For the URL ``/blog/my-blog-post``, the ``slug`` variable gets a value of ``my-blog-post``, which is available -for you to use in your controller (keep reading). +for you to use in your controller (keep reading). The ``blog_show`` is the +internal name of the route, which doesn't have any meaning yet and just needs +to be unique. Later, you'll use it to generate URLs. The ``_controller`` parameter is a special key that tells Symfony which controller should be executed when a URL matches this route. The ``_controller`` string From 17999cfd34ba951eb7cff08b517acdb262e497cb Mon Sep 17 00:00:00 2001 From: Roberto Lombi Date: Fri, 28 Feb 2014 13:29:19 +0100 Subject: [PATCH 17/18] Wrong parameters order and wrong naming Wrong parameters order and wrong naming on "Using Password Encoders" section --- components/security/authentication.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/security/authentication.rst b/components/security/authentication.rst index 11afefa23ff..f010e4cac7e 100644 --- a/components/security/authentication.rst +++ b/components/security/authentication.rst @@ -249,8 +249,8 @@ which should be used to encode this user's password:: // check if the password is valid: $validPassword = $encoder->isPasswordValid( + $encodedPassword, $user->getPassword(), - $password, $user->getSalt()); .. _`CVE-2013-5750`: http://symfony.com/blog/cve-2013-5750-security-issue-in-fosuserbundle-login-form From 02f072a667ce2ef2d9227bd0e24da74614da411a Mon Sep 17 00:00:00 2001 From: WouterJ Date: Wed, 21 May 2014 11:16:20 +0200 Subject: [PATCH 18/18] Applied comments --- components/security/authentication.rst | 28 +++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/components/security/authentication.rst b/components/security/authentication.rst index f010e4cac7e..3abba44dea3 100644 --- a/components/security/authentication.rst +++ b/components/security/authentication.rst @@ -237,21 +237,35 @@ method of the password encoder factory is called with the user object as its first argument, it will return an encoder of type :class:`Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface` which should be used to encode this user's password:: - // fetch a user of type Acme\Entity\LegacyUser - $user = ... + // a Acme\Entity\LegacyUser instance + $user = ...; + + // the password that was submitted, e.g. when registering + $plainPassword = ...; $encoder = $encoderFactory->getEncoder($user); // will return $weakEncoder (see above) + $encodedPassword = $encoder->encodePassword($plainPassword, $user->getSalt()); + + $user->setPassword($encodedPassword); - $encodedPassword = $encoder->encodePassword($password, $user->getSalt()); + // ... save the user - // check if the password is valid: +Now, when you want to check if the submitted password (e.g. when trying to log +in) is correct, you can use:: + + // fetch the Acme\Entity\LegacyUser + $user = ...; + + // the submitted password, e.g. from the login form + $plainPassword = ...; $validPassword = $encoder->isPasswordValid( - $encodedPassword, - $user->getPassword(), - $user->getSalt()); + $user->getPassword(), // the encoded password + $plainPassword, // the submitted password + $user->getSalt() + ); .. _`CVE-2013-5750`: http://symfony.com/blog/cve-2013-5750-security-issue-in-fosuserbundle-login-form .. _`BasePasswordEncoder::checkPasswordLength`: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php