From 1a587c51c28ff7ab7a590e74f39c08d65aa0a33f Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sun, 1 Mar 2015 16:15:22 +0100 Subject: [PATCH 01/41] Added February changelog --- changelog.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog.rst b/changelog.rst index d718537af87..e5116fa08ab 100644 --- a/changelog.rst +++ b/changelog.rst @@ -12,13 +12,13 @@ documentation. Do you also want to participate in the Symfony Documentation? Take a look at the ":doc:`/contributing/documentation/overview`" article. - February, 2015 -------------- New Documentation ~~~~~~~~~~~~~~~~~ +- `16dcf53 `_ #4980 [#4974] Added Twig loader priority Documentation (wizhippo) - `a25da10 `_ #4966 [#4231] Clarify that only the main command triggers events (riperez) - `c6bea37 `_ #4957 Added a mention to the @Security annotation (javiereguiluz) - `9cce63c `_ #4924 [swiftmailer] Document whitelist option to email redirect (TerjeBr) @@ -44,10 +44,13 @@ Minor Documentation Changes - `ff44111 `_ Merge branch '2.3' into 2.5 - `2a29225 `_ #4985 Fixed a typo (javiereguiluz) - `f75bc2b `_ #4972 Fix typos (ifdattic) +- `89e626f `_ #4952 symfony 2.7 requires at least php 5.3.9 (scaytrase) - `9fab10b `_ #4854 Removed no longer needed information about PHP 5.3 (WouterJ) - `1726054 `_ #4500 Link to standard edition (harikt) - `91ff6f8 `_ #4329 ensure consistency with the note (greg0ire) +- `f4ab4b6 `_ #5002 Revert very bad merge (WouterJ) - `e5dbd49 `_ #4977 Unnecessary comma (edsonmedina) +- `ed80100 `_ #4977 Unnecessary comma (edsonmedina) - `5d44987 `_ #4991 Fixed typo and tweaked syntax. (cdvrooman) - `b1aadbf `_ #4993 Bumped symfony version number to 2.6 in flat php composer.json example (TSchuermans) - `3845c9c `_ #4979 require_once path fixed (mvanmeerbeck) From 653ac94c95a82de79984bbf62152451431310b7f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 2 Mar 2015 08:59:59 +0100 Subject: [PATCH 02/41] fix changelog syntax Terminate the `tip` directive with a blank line. --- changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.rst b/changelog.rst index e5116fa08ab..a23cd8ad4c0 100644 --- a/changelog.rst +++ b/changelog.rst @@ -12,6 +12,7 @@ documentation. Do you also want to participate in the Symfony Documentation? Take a look at the ":doc:`/contributing/documentation/overview`" article. + February, 2015 -------------- From e84182d009949532a8bec606a51f79d15e813d3d Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sun, 5 Apr 2015 17:28:59 +0200 Subject: [PATCH 03/41] Added March changelog --- changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.rst b/changelog.rst index ec6efa1d502..c5460dec526 100644 --- a/changelog.rst +++ b/changelog.rst @@ -106,6 +106,7 @@ Minor Documentation Changes - `3be0081 `_ #4976 Improved sentence (edsonmedina) - `a444220 `_ #4885 Fix typos (ifdattic) - `482502d `_ #4793 [Contributing] Several tweaks (xelaris) +- `a2395ef `_ #5054 [Changelog] fix changelog syntax (xabbuh) - `6b66f03 `_ #5003 Updated the generic Deployment article (javiereguiluz) - `39a1487 `_ #4999 Fixed semantic error (beni0888) From 0c089ec73a3aa77321c961cf6e982497328e3faf Mon Sep 17 00:00:00 2001 From: jackdelin Date: Thu, 28 May 2015 17:13:09 +0300 Subject: [PATCH 04/41] Update create_form_type_extension.rst --- cookbook/form/create_form_type_extension.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/form/create_form_type_extension.rst b/cookbook/form/create_form_type_extension.rst index 651d53ce849..ab1703c7596 100644 --- a/cookbook/form/create_form_type_extension.rst +++ b/cookbook/form/create_form_type_extension.rst @@ -195,7 +195,7 @@ it in the view:: use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; use Symfony\Component\PropertyAccess\PropertyAccess; - use Symfony\Component\OptionsResolver\OptionsResolverInterface; + use Symfony\Component\OptionsResolver\OptionsResolver; class ImageTypeExtension extends AbstractTypeExtension { From d01d7ab2abc442b5a2a62ede3f59f80ed30659e9 Mon Sep 17 00:00:00 2001 From: Tomas Date: Wed, 10 Jun 2015 09:55:12 +0300 Subject: [PATCH 05/41] Remove deprecated parameters --- reference/twig_reference.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 65b866e54a3..b45f0f72d02 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -98,16 +98,12 @@ asset .. code-block:: jinja - {{ asset(path, packageName, absolute = false, version = null) }} + {{ asset(path, packageName = null) }} ``path`` **type**: ``string`` ``packageName`` **type**: ``string`` | ``null`` **default**: ``null`` -``absolute`` - **type**: ``boolean`` **default**: ``false`` -``version`` - **type**: ``string`` **default** ``null`` Returns a public path to ``path``, which takes into account the base path set for the package and the URL path. More information in From 135d4b88820f99a399b2929da99dd64b7e585f7a Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sun, 9 Aug 2015 20:42:01 +0200 Subject: [PATCH 06/41] Added July changelog --- changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.rst b/changelog.rst index f888e4fcf7f..fa1de5273db 100644 --- a/changelog.rst +++ b/changelog.rst @@ -19,6 +19,7 @@ July, 2015 New Documentation ~~~~~~~~~~~~~~~~~ +* `#5374 `_ Remove deprecated parameters (norkunas) * `#5533 `_ Replace Capifony with Capistrano/symfony (mojzis) * `#5543 `_ Add deprecation notice to "choice_list" option of ChoiceType (XitasoChris) * `#5521 `_ [Cookbook][WebServer] #5504 add a tip for the --force option (vincentaubert) From feb2ab11613f79203310660193cd5315c8d307e7 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Wed, 29 Jul 2015 16:55:28 +0200 Subject: [PATCH 07/41] Remove mentions of Symfony1 --- .../event_dispatcher/before_after_filters.rst | 8 +- cookbook/index.rst | 1 - cookbook/map.rst.inc | 4 - cookbook/symfony1.rst | 369 ------------------ 4 files changed, 4 insertions(+), 378 deletions(-) delete mode 100644 cookbook/symfony1.rst diff --git a/cookbook/event_dispatcher/before_after_filters.rst b/cookbook/event_dispatcher/before_after_filters.rst index d1c5acddbf8..8a1e71e17c3 100644 --- a/cookbook/event_dispatcher/before_after_filters.rst +++ b/cookbook/event_dispatcher/before_after_filters.rst @@ -8,10 +8,10 @@ It is quite common in web application development to need some logic to be executed just before or just after your controller actions acting as filters or hooks. -In symfony1, this was achieved with the preExecute and postExecute methods. -Most major frameworks have similar methods but there is no such thing in Symfony. -The good news is that there is a much better way to interfere with the -Request -> Response process using the :doc:`EventDispatcher component `. +Some web frameworks define methods like ``preExecute()`` and ``postExecute()``, +but there is no such thing in Symfony. The good news is that there is a much +better way to interfere with the Request -> Response process using the +:doc:`EventDispatcher component `. Token Validation Example ------------------------ diff --git a/cookbook/index.rst b/cookbook/index.rst index bdf414d6177..ba0f13c6fc1 100644 --- a/cookbook/index.rst +++ b/cookbook/index.rst @@ -29,7 +29,6 @@ The Cookbook service_container/index session/index psr7 - symfony1 templating/index testing/index upgrade/index diff --git a/cookbook/map.rst.inc b/cookbook/map.rst.inc index b7563d7f6b8..0540ef3be5b 100644 --- a/cookbook/map.rst.inc +++ b/cookbook/map.rst.inc @@ -209,10 +209,6 @@ * :doc:`/cookbook/psr7` -* **symfony1** - - * :doc:`/cookbook/symfony1` - * :doc:`/cookbook/templating/index` * :doc:`/cookbook/templating/global_variables` diff --git a/cookbook/symfony1.rst b/cookbook/symfony1.rst deleted file mode 100644 index b800914a661..00000000000 --- a/cookbook/symfony1.rst +++ /dev/null @@ -1,369 +0,0 @@ -.. index:: - single: symfony1 - -How Symfony2 Differs from Symfony1 -================================== - -The Symfony2 Framework embodies a significant evolution when compared with -the first version of the framework. Fortunately, with the MVC architecture -at its core, the skills used to master a symfony1 project continue to be -very relevant when developing in Symfony2. Sure, ``app.yml`` is gone, but -routing, controllers and templates all remain. - -This chapter walks through the differences between symfony1 and Symfony2. -As you'll see, many tasks are tackled in a slightly different way. You'll -come to appreciate these minor differences as they promote stable, predictable, -testable and decoupled code in your Symfony2 applications. - -So, sit back and relax as you travel from "then" to "now". - -Directory Structure -------------------- - -When looking at a Symfony2 project - for example, the `Symfony Standard Edition`_ - -you'll notice a very different directory structure than in symfony1. The -differences, however, are somewhat superficial. - -The ``app/`` Directory -~~~~~~~~~~~~~~~~~~~~~~ - -In symfony1, your project has one or more applications, and each lives inside -the ``apps/`` directory (e.g. ``apps/frontend``). By default in Symfony2, -you have just one application represented by the ``app/`` directory. Like -in symfony1, the ``app/`` directory contains configuration specific to that -application. It also contains application-specific cache, log and template -directories as well as a ``Kernel`` class (``AppKernel``), which is the base -object that represents the application. - -Unlike symfony1, almost no PHP code lives in the ``app/`` directory. This -directory is not meant to house modules or library files as it did in symfony1. -Instead, it's simply the home of configuration and other resources (templates, -translation files). - -The ``src/`` Directory -~~~~~~~~~~~~~~~~~~~~~~ - -Put simply, your actual code goes here. In Symfony2, all actual application-code -lives inside a bundle (roughly equivalent to a symfony1 plugin) and, by default, -each bundle lives inside the ``src`` directory. In that way, the ``src`` -directory is a bit like the ``plugins`` directory in symfony1, but much more -flexible. Additionally, while *your* bundles will live in the ``src/`` directory, -third-party bundles will live somewhere in the ``vendor/`` directory. - -To get a better picture of the ``src/`` directory, first think of the structure -of a symfony1 application. First, part of your code likely lives inside one or -more applications. Most commonly these include modules, but could also include -any other PHP classes you put in your application. You may have also created -a ``schema.yml`` file in the ``config`` directory of your project and built -several model files. Finally, to help with some common functionality, you're -using several third-party plugins that live in the ``plugins/`` directory. -In other words, the code that drives your application lives in many different -places. - -In Symfony2, life is much simpler because *all* Symfony2 code must live in -a bundle. In the pretend symfony1 project, all the code *could* be moved -into one or more plugins (which is a very good practice, in fact). Assuming -that all modules, PHP classes, schema, routing configuration, etc. were moved -into a plugin, the symfony1 ``plugins/`` directory would be very similar -to the Symfony2 ``src/`` directory. - -Put simply again, the ``src/`` directory is where your code, assets, -templates and most anything else specific to your project will live. - -The ``vendor/`` Directory -~~~~~~~~~~~~~~~~~~~~~~~~~ - -The ``vendor/`` directory is basically equivalent to the ``lib/vendor/`` -directory in symfony1, which was the conventional directory for all vendor -libraries and bundles. By default, you'll find the Symfony2 library files in -this directory, along with several other dependent libraries such as Doctrine2, -Twig and Swift Mailer. 3rd party Symfony2 bundles live somewhere in the -``vendor/``. - -The ``web/`` Directory -~~~~~~~~~~~~~~~~~~~~~~ - -Not much has changed in the ``web/`` directory. The most noticeable difference -is the absence of the ``css/``, ``js/`` and ``images/`` directories. This -is intentional. Like with your PHP code, all assets should also live inside -a bundle. With the help of a console command, the ``Resources/public/`` -directory of each bundle is copied or symbolically-linked to the ``web/bundles/`` -directory. This allows you to keep assets organized inside your bundle, but -still make them available to the public. To make sure that all bundles are -available, run the following command: - -.. code-block:: bash - - $ php app/console assets:install web - -.. note:: - - This command is the Symfony2 equivalent to the symfony1 ``plugin:publish-assets`` - command. - -Autoloading ------------ - -One of the advantages of modern frameworks is never needing to worry about -requiring files. By making use of an autoloader, you can refer to any class -in your project and trust that it's available. Autoloading has changed in -Symfony2 to be more universal, faster, and independent of needing to clear -your cache. - -In symfony1, autoloading was done by searching the entire project for the -presence of PHP class files and caching this information in a giant array. -That array told symfony1 exactly which file contained each class. In the -production environment, this caused you to need to clear the cache when classes -were added or moved. - -In Symfony2, a tool named `Composer`_ handles this process. -The idea behind the autoloader is simple: the name of your class (including -the namespace) must match up with the path to the file containing that class. -Take the FrameworkExtraBundle from the Symfony2 Standard Edition as an -example:: - - namespace Sensio\Bundle\FrameworkExtraBundle; - - use Symfony\Component\HttpKernel\Bundle\Bundle; - // ... - - class SensioFrameworkExtraBundle extends Bundle - { - // ... - } - -The file itself lives at -``vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/SensioFrameworkExtraBundle.php``. -As you can see, the second part of the path follows the namespace of the -class. The first part is equal to the package name of the SensioFrameworkExtraBundle. - -The namespace, ``Sensio\Bundle\FrameworkExtraBundle``, and package name, -``sensio/framework-extra-bundle``, spells out the directory that the file -should live in -(``vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/``). -Composer can then look for the file at this specific place and load it very -fast. - -If the file did *not* live at this exact location, you'd receive a -``Class "Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle" does not exist.`` -error. In Symfony2, a "class does not exist" error means that the namespace of -the class and physical location do not match. Basically, Symfony2 is looking -in one exact location for that class, but that location doesn't exist (or -contains a different class). In order for a class to be autoloaded, you -**never need to clear your cache** in Symfony2. - -As mentioned before, for the autoloader to work, it needs to know that the -``Sensio`` namespace lives in the ``vendor/sensio/framework-extra-bundle`` -directory and that, for example, the ``Doctrine`` namespace lives in the -``vendor/doctrine/orm/lib/`` directory. This mapping is entirely controlled by -Composer. Each third-party library you load through Composer has its -settings defined and Composer takes care of everything for you. - -For this to work, all third-party libraries used by your project must be -defined in the ``composer.json`` file. - -If you look at the ``HelloController`` from the Symfony Standard Edition you -can see that it lives in the ``Acme\DemoBundle\Controller`` namespace. Yet, the -AcmeDemoBundle is not defined in your ``composer.json`` file. Nonetheless are -the files autoloaded. This is because you can tell Composer to autoload files -from specific directories without defining a dependency: - -.. code-block:: json - - "autoload": { - "psr-0": { "": "src/" } - } - -This means that if a class is not found in the ``vendor`` directory, Composer -will search in the ``src`` directory before throwing a "class does not exist" -exception. Read more about configuring the Composer autoloader in -`the Composer documentation`_. - -Using the Console ------------------ - -In symfony1, the console is in the root directory of your project and is -called ``symfony``: - -.. code-block:: bash - - $ php symfony - -In Symfony2, the console is now in the app sub-directory and is called -``console``: - -.. code-block:: bash - - $ php app/console - -Applications ------------- - -In a symfony1 project, it is common to have several applications: one for the -front-end and one for the back-end for instance. - -In a Symfony2 project, you only need to create one application (a blog -application, an intranet application, ...). Most of the time, if you want to -create a second application, you might instead create another project and -share some bundles between them. - -And if you need to separate the front-end and the back-end features of some -bundles, you can create sub-namespaces for controllers, sub-directories for -templates, different semantic configurations, separate routing configurations, -and so on. - -Of course, there's nothing wrong with having multiple applications in your -project, that's entirely up to you. A second application would mean a new -directory, e.g. ``my_app/``, with the same basic setup as the ``app/`` directory. - -.. tip:: - - Read the definition of a :term:`Project`, an :term:`Application`, and a - :term:`Bundle` in the glossary. - -Bundles and Plugins -------------------- - -In a symfony1 project, a plugin could contain configuration, modules, PHP -libraries, assets and anything else related to your project. In Symfony2, -the idea of a plugin is replaced by the "bundle". A bundle is even more powerful -than a plugin because the core Symfony2 Framework is brought in via a series -of bundles. In Symfony2, bundles are first-class citizens that are so flexible -that even core code itself is a bundle. - -In symfony1, a plugin must be enabled inside the ``ProjectConfiguration`` -class:: - - // config/ProjectConfiguration.class.php - public function setup() - { - // some plugins here - $this->enableAllPluginsExcept(array(...)); - } - -In Symfony2, the bundles are activated inside the application kernel:: - - // app/AppKernel.php - public function registerBundles() - { - $bundles = array( - new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), - new Symfony\Bundle\TwigBundle\TwigBundle(), - ..., - new Acme\DemoBundle\AcmeDemoBundle(), - ); - - return $bundles; - } - -Routing (``routing.yml``) and Configuration (``config.yml``) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In symfony1, the ``routing.yml`` and ``app.yml`` configuration files were -automatically loaded inside any plugin. In Symfony2, routing and application -configuration inside a bundle must be included manually. For example, to -include a routing resource from a bundle called AcmeDemoBundle, you can -do the following: - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/routing.yml - _hello: - resource: "@AcmeDemoBundle/Resources/config/routing.yml" - - .. code-block:: xml - - - - - - - - - - .. code-block:: php - - // app/config/routing.php - use Symfony\Component\Routing\RouteCollection; - - $collection = new RouteCollection(); - $collection->addCollection($loader->import("@AcmeHelloBundle/Resources/config/routing.php")); - - return $collection; - -This will load the routes found in the ``Resources/config/routing.yml`` file -of the AcmeDemoBundle. The special ``@AcmeDemoBundle`` is a shortcut syntax -that, internally, resolves to the full path to that bundle. - -You can use this same strategy to bring in configuration from a bundle: - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/config.yml - imports: - - { resource: "@AcmeDemoBundle/Resources/config/config.yml" } - - .. code-block:: xml - - - - - - - .. code-block:: php - - // app/config/config.php - $this->import('@AcmeDemoBundle/Resources/config/config.php') - -In Symfony2, configuration is a bit like ``app.yml`` in symfony1, except much -more systematic. With ``app.yml``, you could simply create any keys you wanted. -By default, these entries were meaningless and depended entirely on how you -used them in your application: - -.. code-block:: yaml - - # some app.yml file from symfony1 - all: - email: - from_address: foo.bar@example.com - -In Symfony2, you can also create arbitrary entries under the ``parameters`` -key of your configuration: - -.. configuration-block:: - - .. code-block:: yaml - - parameters: - email.from_address: foo.bar@example.com - - .. code-block:: xml - - - foo.bar@example.com - - - .. code-block:: php - - $container->setParameter('email.from_address', 'foo.bar@example.com'); - -You can now access this from a controller, for example:: - - public function helloAction($name) - { - $fromAddress = $this->container->getParameter('email.from_address'); - } - -In reality, the Symfony2 configuration is much more powerful and is used -primarily to configure objects that you can use. For more information, see -the chapter titled ":doc:`/book/service_container`". - -.. _`Composer`: https://getcomposer.org -.. _`Symfony Standard Edition`: https://github.com/symfony/symfony-standard -.. _`the Composer documentation`: https://getcomposer.org/doc/04-schema.md#autoload From 1941e85f333cf117664d25c3dd8d8f9789443403 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Fri, 28 Aug 2015 04:42:32 -0400 Subject: [PATCH 08/41] [#5480] Adding missing map entry (added 2 so it's easier to find) --- contributing/map.rst.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contributing/map.rst.inc b/contributing/map.rst.inc index 84344670d90..22c759821e4 100644 --- a/contributing/map.rst.inc +++ b/contributing/map.rst.inc @@ -2,6 +2,7 @@ * :doc:`Bugs ` * :doc:`Patches ` + * :doc:`Reviewing Issues and Patches ` * :doc:`The Core Team ` * :doc:`Security ` * :doc:`Tests ` @@ -22,4 +23,5 @@ * **Community** * :doc:`Release Process ` + * :doc:`Community Reviews ` * :doc:`Other Resources ` From bb2f9918a54f2867ba7b736bb1bc1e07b563b453 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Tue, 1 Sep 2015 20:48:39 +0200 Subject: [PATCH 09/41] Added August changelog --- changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.rst b/changelog.rst index c2ada55f759..4bd7f28e62b 100644 --- a/changelog.rst +++ b/changelog.rst @@ -38,6 +38,7 @@ Minor Documentation Changes * `#5553 `_ Fix all broken links/permanent redirects/removed anchors (WouterJ) * `#5650 `_ [RFR] fixing typo and removing duplicated lines in Config component doc (salahm) * `#5635 `_ Fix minor problems in book/page_creation.rst (fabschurt) +* `#5579 `_ [3.0] Remove mentions of Symfony1 (WouterJ) * `#5647 `_ don't ignore the _exts directory anymore (xabbuh) * `#5587 `_ [2.6] Don't use deprecated features (WouterJ) * `#5637 `_ Add QueryBuilder vs DQL section (bocharsky-bw) From 8794a4d04327f56a39107a40d5b3ee67b0748bc1 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 10:33:16 +0100 Subject: [PATCH 10/41] app/console -> bin/console --- book/bundles.rst | 2 +- book/configuration.rst | 6 +++--- book/controller.rst | 2 +- book/doctrine.rst | 24 ++++++++++++------------ book/installation.rst | 10 +++++----- book/page_creation.rst | 4 ++-- book/routing.rst | 6 +++--- book/security.rst | 2 +- book/service_container.rst | 6 +++--- book/templating.rst | 8 ++++---- book/translation.rst | 10 +++++----- 11 files changed, 40 insertions(+), 40 deletions(-) diff --git a/book/bundles.rst b/book/bundles.rst index ff09cc6fc3e..0fdfcfc088f 100644 --- a/book/bundles.rst +++ b/book/bundles.rst @@ -122,7 +122,7 @@ generating a basic bundle skeleton: .. code-block:: bash - $ php app/console generate:bundle --namespace=Acme/TestBundle + $ php bin/console generate:bundle --namespace=Acme/TestBundle The bundle skeleton generates a basic controller, template and routing resource that can be customized. You'll learn more about Symfony's command-line diff --git a/book/configuration.rst b/book/configuration.rst index da32a0e1afe..e307d464e26 100644 --- a/book/configuration.rst +++ b/book/configuration.rst @@ -122,13 +122,13 @@ FrameworkBundle configuration: .. code-block:: bash - $ app/console config:dump-reference FrameworkBundle + $ bin/console config:dump-reference FrameworkBundle The extension alias (configuration key) can also be used: .. code-block:: bash - $ app/console config:dump-reference framework + $ bin/console config:dump-reference framework .. note:: @@ -177,7 +177,7 @@ cached files and allow them to rebuild: .. code-block:: bash - $ php app/console cache:clear --env=prod --no-debug + $ php bin/console cache:clear --env=prod --no-debug .. note:: diff --git a/book/controller.rst b/book/controller.rst index cc7774d85b2..449e98b69e8 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -532,7 +532,7 @@ console command: .. code-block:: bash - $ php app/console debug:container + $ php bin/console debug:container .. versionadded:: 2.6 Prior to Symfony 2.6, this command was called ``container:debug``. diff --git a/book/doctrine.rst b/book/doctrine.rst index 87e894c1f45..e91ce4ec729 100644 --- a/book/doctrine.rst +++ b/book/doctrine.rst @@ -116,7 +116,7 @@ for you: .. code-block:: bash - $ php app/console doctrine:database:create + $ php bin/console doctrine:database:create .. sidebar:: Setting up the Database to be UTF8 @@ -128,8 +128,8 @@ for you: .. code-block:: bash - $ php app/console doctrine:database:drop --force - $ php app/console doctrine:database:create + $ php bin/console doctrine:database:drop --force + $ php bin/console doctrine:database:create There's no way to configure these defaults inside Doctrine, as it tries to be as agnostic as possible in terms of environment configuration. One way to solve @@ -227,7 +227,7 @@ just a simple PHP class. .. code-block:: bash - $ php app/console doctrine:generate:entity + $ php bin/console doctrine:generate:entity .. index:: single: Doctrine; Adding mapping metadata @@ -392,7 +392,7 @@ a regular PHP class, you need to create getter and setter methods (e.g. ``getNam .. code-block:: bash - $ php app/console doctrine:generate:entities AppBundle/Entity/Product + $ php bin/console doctrine:generate:entities AppBundle/Entity/Product This command makes sure that all the getters and setters are generated for the ``Product`` class. This is a safe command - you can run it over and @@ -434,10 +434,10 @@ mapping information) of a bundle or an entire namespace: .. code-block:: bash # generates all entities in the AppBundle - $ php app/console doctrine:generate:entities AppBundle + $ php bin/console doctrine:generate:entities AppBundle # generates all entities of bundles in the Acme namespace - $ php app/console doctrine:generate:entities Acme + $ php bin/console doctrine:generate:entities Acme .. note:: @@ -459,7 +459,7 @@ in your application. To do this, run: .. code-block:: bash - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force .. tip:: @@ -852,7 +852,7 @@ used earlier to generate the missing getter and setter methods: .. code-block:: bash - $ php app/console doctrine:generate:entities AppBundle + $ php bin/console doctrine:generate:entities AppBundle Next, add a new method - ``findAllOrderedByName()`` - to the newly generated repository class. This method will query for all the ``Product`` entities, @@ -906,7 +906,7 @@ you can let Doctrine create the class for you. .. code-block:: bash - $ php app/console doctrine:generate:entity --no-interaction \ + $ php bin/console doctrine:generate:entity --no-interaction \ --entity="AppBundle:Category" \ --fields="name:string(255)" @@ -1063,7 +1063,7 @@ methods for you: .. code-block:: bash - $ php app/console doctrine:generate:entities AppBundle + $ php bin/console doctrine:generate:entities AppBundle Ignore the Doctrine metadata for a moment. You now have two classes - ``Category`` and ``Product`` with a natural one-to-many relationship. The ``Category`` @@ -1092,7 +1092,7 @@ table, and ``product.category_id`` column, and new foreign key: .. code-block:: bash - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force .. note:: diff --git a/book/installation.rst b/book/installation.rst index 407cfc36704..898aeb24e1a 100644 --- a/book/installation.rst +++ b/book/installation.rst @@ -164,7 +164,7 @@ browsing the project directory and executing this command: .. code-block:: bash $ cd my_project_name/ - $ php app/console server:run + $ php bin/console server:run Then, open your browser and access the ``http://localhost:8000/`` URL to see the Welcome Page of Symfony: @@ -195,7 +195,7 @@ server with the ``server:stop`` command: .. code-block:: bash - $ php app/console server:stop + $ php bin/console server:stop Checking Symfony Application Configuration and Setup ---------------------------------------------------- @@ -265,7 +265,7 @@ If there are any issues, correct them now before moving on. If none of the previous methods work for you, change the umask so that the cache and log directories will be group-writable or world-writable (depending if the web server user and the command line user are in the same group or not). - To achieve this, put the following line at the beginning of the ``app/console``, + To achieve this, put the following line at the beginning of the ``bin/console``, ``web/app.php`` and ``web/app_dev.php`` files:: umask(0002); // This will let the permissions be 0775 @@ -306,7 +306,7 @@ several minutes to complete. .. code-block:: bash - $ php app/console security:check + $ php bin/console security:check A good security practice is to execute this command regularly to be able to update or replace compromised dependencies as soon as possible. @@ -331,7 +331,7 @@ of the Symfony Installer anywhere in your system: c:\projects\> php symfony demo Once downloaded, enter into the ``symfony_demo/`` directory and run the PHP's -built-in web server executing the ``php app/console server:run`` command. Access +built-in web server executing the ``php bin/console server:run`` command. Access to the ``http://localhost:8000`` URL in your browser to start using the Symfony Demo application. diff --git a/book/page_creation.rst b/book/page_creation.rst index c062182d5f8..e450fbd61e9 100644 --- a/book/page_creation.rst +++ b/book/page_creation.rst @@ -544,11 +544,11 @@ by changing one option in this configuration file. To find out how, see the :doc:`Configuration Reference ` section. Or, to get a big example dump of all of the valid configuration under a key, -use the handy ``app/console`` command: +use the handy ``bin/console`` command: .. code-block:: bash - $ app/console config:dump-reference framework + $ bin/console config:dump-reference framework There's a lot more power behind Symfony's configuration system, including environments, imports and parameters. To learn all of it, see the diff --git a/book/routing.rst b/book/routing.rst index ed0b4bf809c..e9cc99fc127 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -1393,7 +1393,7 @@ the command by running the following from the root of your project. .. code-block:: bash - $ php app/console debug:router + $ php bin/console debug:router .. versionadded:: 2.6 Prior to Symfony 2.6, this command was called ``router:debug``. @@ -1415,14 +1415,14 @@ the route name after the command: .. code-block:: bash - $ php app/console debug:router article_show + $ php bin/console debug:router article_show Likewise, if you want to test whether a URL matches a given route, you can use the ``router:match`` console command: .. code-block:: bash - $ php app/console router:match /blog/my-latest-post + $ php bin/console router:match /blog/my-latest-post This command will print which route the URL matches. diff --git a/book/security.rst b/book/security.rst index 094bb487bfe..5f410cac2ac 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1363,7 +1363,7 @@ security vulnerability in your installed dependencies: .. code-block:: bash - $ php app/console security:check + $ php bin/console security:check A good security practice is to execute this command regularly to be able to update or replace compromised dependencies as soon as possible. Internally, diff --git a/book/service_container.rst b/book/service_container.rst index 2cb08ae4078..07845abad72 100644 --- a/book/service_container.rst +++ b/book/service_container.rst @@ -1147,7 +1147,7 @@ console. To show all services and the class for each service, run: .. code-block:: bash - $ php app/console debug:container + $ php bin/console debug:container .. versionadded:: 2.6 Prior to Symfony 2.6, this command was called ``container:debug``. @@ -1156,7 +1156,7 @@ By default, only public services are shown, but you can also view private servic .. code-block:: bash - $ php app/console debug:container --show-private + $ php bin/console debug:container --show-private .. note:: @@ -1170,7 +1170,7 @@ its id: .. code-block:: bash - $ php app/console debug:container my_mailer + $ php bin/console debug:container my_mailer Learn more ---------- diff --git a/book/templating.rst b/book/templating.rst index 4c1de72f752..26bfde3daee 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -1211,7 +1211,7 @@ should use the ``parent()`` Twig function to include everything from the ``style block of the base template. You can also include assets located in your bundles' ``Resources/public`` folder. -You will need to run the ``php app/console assets:install target [--symlink]`` +You will need to run the ``php bin/console assets:install target [--symlink]`` command, which moves (or symlinks) files into the correct location. (target is by default "web"). @@ -1391,7 +1391,7 @@ to create it). You're now free to customize the template. .. caution:: If you add a template in a new location, you *may* need to clear your - cache (``php app/console cache:clear``), even if you are in debug mode. + cache (``php bin/console cache:clear``), even if you are in debug mode. This logic also applies to base bundle templates. Suppose also that each template in AcmeBlogBundle inherits from a base template called @@ -1641,10 +1641,10 @@ console command: .. code-block:: bash # You can check by filename: - $ php app/console lint:twig app/Resources/views/article/recent_list.html.twig + $ php bin/console lint:twig app/Resources/views/article/recent_list.html.twig # or by directory: - $ php app/console lint:twig app/Resources/views + $ php bin/console lint:twig app/Resources/views .. _template-formats: diff --git a/book/translation.rst b/book/translation.rst index 7cd2fe0e8a9..3e02f2e65bf 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -387,7 +387,7 @@ For more options, see :ref:`component-translator-message-catalogs`. .. code-block:: bash - $ php app/console cache:clear + $ php bin/console cache:clear .. _book-translation-fallback: @@ -815,7 +815,7 @@ To inspect all messages in the ``fr`` locale for the AcmeDemoBundle, run: .. code-block:: bash - $ php app/console debug:translation fr AcmeDemoBundle + $ php bin/console debug:translation fr AcmeDemoBundle You will get this output: @@ -856,15 +856,15 @@ By default all domains are inspected, but it is possible to specify a single dom .. code-block:: bash - $ php app/console debug:translation en AcmeDemoBundle --domain=messages + $ php bin/console debug:translation en AcmeDemoBundle --domain=messages When bundles have a lot of messages, it is useful to display only the unused or only the missing messages, by using the ``--only-unused`` or ``--only-missing`` switches: .. code-block:: bash - $ php app/console debug:translation en AcmeDemoBundle --only-unused - $ php app/console debug:translation en AcmeDemoBundle --only-missing + $ php bin/console debug:translation en AcmeDemoBundle --only-unused + $ php bin/console debug:translation en AcmeDemoBundle --only-missing Summary ------- From 1461bdcf4e7ac8d7a0304ad30782e1987a03443b Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 10:35:16 +0100 Subject: [PATCH 11/41] app/phpunit.xml.dist -> phpunit.xml.dist --- book/testing.rst | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/book/testing.rst b/book/testing.rst index 9dc85d4cba8..59d2c2c5428 100644 --- a/book/testing.rst +++ b/book/testing.rst @@ -28,11 +28,10 @@ command: .. code-block:: bash # specify the configuration directory on the command line - $ phpunit -c app/ + $ phpunit -The ``-c`` option tells PHPUnit to look in the ``app/`` directory for a configuration -file. If you're curious about the PHPUnit options, check out the ``app/phpunit.xml.dist`` -file. +PHPunit is configured by the ``phpunit.xml.dist`` file in the root of your +Symfony application. .. tip:: @@ -93,23 +92,23 @@ of your bundle:: Just like in your real application - autoloading is automatically enabled via the ``bootstrap.php.cache`` file (as configured by default in the -``app/phpunit.xml.dist`` file). +``phpunit.xml.dist`` file). Running tests for a given file or directory is also very easy: .. code-block:: bash # run all tests of the application - $ phpunit -c app + $ phpunit # run all tests in the Util directory - $ phpunit -c app src/AppBundle/Tests/Util + $ phpunit src/AppBundle/Tests/Util # run tests for the Calculator class - $ phpunit -c app src/AppBundle/Tests/Util/CalculatorTest.php + $ phpunit src/AppBundle/Tests/Util/CalculatorTest.php # run all tests for the entire Bundle - $ phpunit -c app src/AppBundle/ + $ phpunit src/AppBundle/ .. index:: single: Tests; Functional tests @@ -802,23 +801,23 @@ PHPUnit Configuration ~~~~~~~~~~~~~~~~~~~~~ Each application has its own PHPUnit configuration, stored in the -``app/phpunit.xml.dist`` file. You can edit this file to change the defaults or -create an ``app/phpunit.xml`` file to set up a configuration for your local -machine only. +``phpunit.xml.dist`` file. You can edit this file to change the defaults or +create an ``phpunit.xml`` file to set up a configuration for your local machine +only. .. tip:: - Store the ``app/phpunit.xml.dist`` file in your code repository and ignore - the ``app/phpunit.xml`` file. + Store the ``phpunit.xml.dist`` file in your code repository and ignore + the ``phpunit.xml`` file. By default, only the tests from your own custom bundles stored in the standard directories ``src/*/*Bundle/Tests``, ``src/*/Bundle/*Bundle/Tests``, ``src/*Bundle/Tests`` are run by the ``phpunit`` command, as configured -in the ``app/phpunit.xml.dist`` file: +in the ``phpunit.xml.dist`` file: .. code-block:: xml - + @@ -836,7 +835,7 @@ configuration adds tests from a custom ``lib/tests`` directory: .. code-block:: xml - + @@ -853,7 +852,7 @@ section: .. code-block:: xml - + From 3318f2e42ac6139cbe57cda1bf5cc9468e5b4cb3 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 10:37:15 +0100 Subject: [PATCH 12/41] app/(cache|logs) -> var/(cache|logs) --- book/installation.rst | 16 ++++++++-------- book/templating.rst | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/book/installation.rst b/book/installation.rst index 898aeb24e1a..5983a8f39ec 100644 --- a/book/installation.rst +++ b/book/installation.rst @@ -214,8 +214,8 @@ If there are any issues, correct them now before moving on. .. sidebar:: Setting up Permissions - One common issue when installing Symfony is that the ``app/cache`` and - ``app/logs`` directories must be writable both by the web server and the + One common issue when installing Symfony is that the ``var/cache`` and + ``var/logs`` directories must be writable both by the web server and the command line user. On a UNIX system, if your web server user is different from your command line user, you can try one of the following solutions. @@ -236,12 +236,12 @@ If there are any issues, correct them now before moving on. .. code-block:: bash - $ rm -rf app/cache/* - $ rm -rf app/logs/* + $ rm -rf var/cache/* + $ rm -rf var/logs/* $ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1` - $ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs - $ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs + $ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" var/cache var/logs + $ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" var/cache var/logs **3. Using ACL on a system that does not support chmod +a** @@ -255,8 +255,8 @@ If there are any issues, correct them now before moving on. .. code-block:: bash $ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1` - $ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs - $ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs + $ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var/cache var/logs + $ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var/cache var/logs If this doesn't work, try adding ``-n`` option. diff --git a/book/templating.rst b/book/templating.rst index 26bfde3daee..d54495273b3 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -159,7 +159,7 @@ Twig Template Caching Twig is fast. Each Twig template is compiled down to a native PHP class that is rendered at runtime. The compiled classes are located in the -``app/cache/{environment}/twig`` directory (where ``{environment}`` is the +``var/cache/{environment}/twig`` directory (where ``{environment}`` is the environment, such as ``dev`` or ``prod``) and in some cases can be useful while debugging. See :ref:`environments-summary` for more information on environments. From 6b5c97737052c5666b0dd3c0674caf8e9ac69ff7 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 10:40:37 +0100 Subject: [PATCH 13/41] app/bootstrap.php.cache -> var/bootstrap.php.cache --- book/http_cache.rst | 5 +---- book/performance.rst | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/book/http_cache.rst b/book/http_cache.rst index bf91ff2345d..24a5b23982f 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -145,12 +145,9 @@ To enable caching, modify the code of a front controller to use the caching kernel:: // web/app.php - require_once __DIR__.'/../app/bootstrap.php.cache'; - require_once __DIR__.'/../app/AppKernel.php'; - require_once __DIR__.'/../app/AppCache.php'; - use Symfony\Component\HttpFoundation\Request; + // ... $kernel = new AppKernel('prod', false); $kernel->loadClassCache(); // wrap the default AppKernel with the AppCache one diff --git a/book/performance.rst b/book/performance.rst index c73ed68c1ee..c60554015b8 100644 --- a/book/performance.rst +++ b/book/performance.rst @@ -75,16 +75,18 @@ If you're using the Standard Distribution, this code should already be available as comments in this file:: // app.php - // ... - - $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; - // Use APC for autoloading to improve performance - // Change 'sf2' by the prefix you want in order - // to prevent key conflict with another application + // ... + $loader = require __DIR__.'/../app/autoload.php'; + include_once __DIR__.'/../var/bootstrap.php.cache'; + // Enable APC for autoloading to improve performance. + // You should change the ApcClassLoader first argument to a unique prefix + // in order to prevent cache key conflicts with other applications + // also using APC. /* - $loader = new ApcClassLoader('sf2', $loader); - $loader->register(true); + $apcLoader = new Symfony\Component\ClassLoader\ApcClassLoader(sha1(__FILE__), $loader); + $loader->unregister(); + $apcLoader->register(true); */ // ... @@ -119,7 +121,7 @@ If you're using the Symfony Standard Edition, then you're probably already using the bootstrap file. To be sure, open your front controller (usually ``app.php``) and check to make sure that the following line exists:: - require_once __DIR__.'/../app/bootstrap.php.cache'; + include_once __DIR__.'/../var/bootstrap.php.cache'; Note that there are two disadvantages when using a bootstrap file: From 0d6941483ea756c2a00a71bd9aa7b5ce3d0c9783 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 10:49:31 +0100 Subject: [PATCH 14/41] Updating 'Exploring the Project' --- book/bundles.rst | 1 + book/page_creation.rst | 49 ++++++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/book/bundles.rst b/book/bundles.rst index 0fdfcfc088f..db7994795c2 100644 --- a/book/bundles.rst +++ b/book/bundles.rst @@ -107,6 +107,7 @@ Now that you've created the bundle, enable it via the ``AppKernel`` class:: { $bundles = array( // ... + // register your bundle new Acme\TestBundle\AcmeTestBundle(), ); diff --git a/book/page_creation.rst b/book/page_creation.rst index e450fbd61e9..c676a0f39ed 100644 --- a/book/page_creation.rst +++ b/book/page_creation.rst @@ -102,8 +102,8 @@ Suppose you want to create a JSON endpoint that returns the lucky number. Just add a second method to ``LuckyController``:: // src/AppBundle/Controller/LuckyController.php - // ... + // ... class LuckyController extends Controller { // ... @@ -132,8 +132,8 @@ Try this out in your browser: You can even shorten this with the handy :class:`Symfony\\Component\\HttpFoundation\\JsonResponse`:: // src/AppBundle/Controller/LuckyController.php - // ... + // ... // --> don't forget this new use statement use Symfony\Component\HttpFoundation\JsonResponse; @@ -168,8 +168,8 @@ at the end: .. code-block:: php-annotations // src/AppBundle/Controller/LuckyController.php - // ... + // ... class LuckyController extends Controller { /** @@ -192,7 +192,7 @@ at the end: .. code-block:: xml - + add this new use statement use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -296,8 +296,8 @@ Twig templates, another that can log messages and many more. To render a Twig template, use a service called ``templating``:: // src/AppBundle/Controller/LuckyController.php - // ... + // ... class LuckyController extends Controller { /** @@ -329,8 +329,8 @@ But this can get even easier! By extending the ``Controller`` class, you also get a lot of shortcut methods, like ``render()``:: // src/AppBundle/Controller/LuckyController.php - // ... + // ... /** * @Route("/lucky/number/{count}") */ @@ -434,30 +434,41 @@ worked inside the two most important directories: else). As you get more advanced, you'll learn what can be done inside each of these. -The ``app/`` directory also holds a few other things, like the cache directory -``app/cache/``, the logs directory ``app/logs/`` and ``app/AppKernel.php``, -which you'll use to enable new bundles (and one of a *very* short list of +The ``app/`` directory also holds some other things, like ``app/AppKernel.php``, +which you'll use to enable new bundles (this is one of a *very* short list of PHP files in ``app/``). The ``src/`` directory has just one directory - ``src/AppBundle`` - and everything lives inside of it. A bundle is like a "plugin" and you can `find open source bundles`_ and install them into your project. But even -*your* code lives in a bundle - typically ``AppBundle`` (though there's -nothing special about ``AppBundle``). To find out more about bundles and +*your* code lives in a bundle - typically *AppBundle* (though there's +nothing special about AppBundle). To find out more about bundles and why you might create multiple bundles (hint: sharing code between projects), see the :doc:`Bundles ` chapter. So what about the other directories in the project? -``vendor/`` - Vendor (i.e. third-party) libraries and bundles are downloaded here by - the `Composer`_ package manager. - ``web/`` This is the document root for the project and contains any publicly accessible files, like CSS, images and the Symfony front controllers that execute the app (``app_dev.php`` and ``app.php``). +``tests/`` + The automatic tests (e.g. Unit tests) of your application live here. + +``bin/`` + The "binary" files live here. The most important one is the ``console`` + file which is used to execute Symfony commands via the console. + +``var/`` + This is were automatically created files are stored, like cache files + (``var/cache/``) and logs (``var/logs/``). + +``vendor/`` + Vendor (i.e. third-party) libraries and bundles are downloaded here by + the `Composer`_ package manager. You should never need to manually edit + something in this directory. + .. seealso:: Symfony is flexible. If you need to, you can easily override the default @@ -475,8 +486,8 @@ is ``app/config/config.yml``: .. code-block:: yaml # app/config/config.yml - # ... + # ... framework: secret: "%secret%" router: @@ -548,7 +559,7 @@ use the handy ``bin/console`` command: .. code-block:: bash - $ bin/console config:dump-reference framework + $ php bin/console config:dump-reference framework There's a lot more power behind Symfony's configuration system, including environments, imports and parameters. To learn all of it, see the From ed430157ae1e07eddf15670d7d44993bd1eddd94 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 10:51:55 +0100 Subject: [PATCH 15/41] Prefix commands with 'php' --- book/configuration.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/configuration.rst b/book/configuration.rst index e307d464e26..da96b334947 100644 --- a/book/configuration.rst +++ b/book/configuration.rst @@ -122,13 +122,13 @@ FrameworkBundle configuration: .. code-block:: bash - $ bin/console config:dump-reference FrameworkBundle + $ php bin/console config:dump-reference FrameworkBundle The extension alias (configuration key) can also be used: .. code-block:: bash - $ bin/console config:dump-reference framework + $ php bin/console config:dump-reference framework .. note:: From 215c36dc1db1fd1fb3ab3d0d3780796ed2fa10c0 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 11:03:33 +0100 Subject: [PATCH 16/41] [BestPractices] Use new directory structure --- best_practices/business-logic.rst | 6 ++- best_practices/creating-the-project.rst | 57 ++++++++++--------------- best_practices/introduction.rst | 4 -- best_practices/tests.rst | 4 +- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/best_practices/business-logic.rst b/best_practices/business-logic.rst index 85f3a14bb0a..4642844bcb4 100644 --- a/best_practices/business-logic.rst +++ b/best_practices/business-logic.rst @@ -21,6 +21,8 @@ Inside here, you can create whatever directories you want to organize things: │ └─ AppBundle/ │ └─ Utils/ │ └─ MyClass.php + ├─ tests/ + ├─ var/ ├─ vendor/ └─ web/ @@ -40,6 +42,8 @@ and put things there: │ │ └─ Utils/ │ │ └─ MyClass.php │ └─ AppBundle/ + ├─ tests/ + ├─ var/ ├─ vendor/ └─ web/ @@ -318,7 +322,7 @@ command: .. code-block:: bash - $ php app/console doctrine:fixtures:load + $ php bin/console doctrine:fixtures:load Careful, database will be purged. Do you want to continue Y/N ? Y > purging database diff --git a/best_practices/creating-the-project.rst b/best_practices/creating-the-project.rst index 60e6db3be55..4ae67d7e342 100644 --- a/best_practices/creating-the-project.rst +++ b/best_practices/creating-the-project.rst @@ -27,14 +27,9 @@ to create files and execute the following commands: .. code-block:: bash - # Linux, Mac OS X $ cd projects/ $ symfony new blog - # Windows - c:\> cd projects/ - c:\projects\> php symfony.phar new blog - This command creates a new directory called ``blog`` that contains a fresh new project based on the most recent stable Symfony version available. In addition, the installer checks if your system meets the technical requirements to execute @@ -58,13 +53,18 @@ number of files and directories generated automatically: blog/ ├─ app/ - │ ├─ console - │ ├─ cache/ │ ├─ config/ - │ ├─ logs/ │ └─ Resources/ + ├─ bin + │ └─ console ├─ src/ │ └─ AppBundle/ + ├─ var/ + │ ├─ cache/ + │ ├─ logs/ + │ └─ sessions/ + ├─ tests/ + │ └─ AppBundle/ ├─ vendor/ └─ web/ @@ -72,13 +72,16 @@ This file and directory hierarchy is the convention proposed by Symfony to structure your applications. The recommended purpose of each directory is the following: -* ``app/cache/``, stores all the cache files generated by the application; * ``app/config/``, stores all the configuration defined for any environment; -* ``app/logs/``, stores all the log files generated by the application; * ``app/Resources/``, stores all the templates and the translation files for the application; * ``src/AppBundle/``, stores the Symfony specific code (controllers and routes), your domain code (e.g. Doctrine classes) and all your business logic; +* ``var/cache/``, stores all the cache files generated by the application; +* ``var/logs/``, stores all the log files generated by the application; +* ``var/sessions/``, stores all the session files generated by the application; +* ``tests/AppBundle/``, stores the automatic tests (e.g. Unit tests) of the + application. * ``vendor/``, this is the directory where Composer installs the application's dependencies and you should never modify any of its contents; * ``web/``, stores all the front controller files and all the web assets, such @@ -123,13 +126,18 @@ that follows these best practices: blog/ ├─ app/ - │ ├─ console - │ ├─ cache/ │ ├─ config/ - │ ├─ logs/ │ └─ Resources/ + ├─ bin/ + │ └─ console ├─ src/ │ └─ AppBundle/ + ├─ tests/ + │ └─ AppBundle/ + ├─ var/ + │ ├─ cache/ + │ ├─ logs/ + └─ sessions/ ├─ vendor/ └─ web/ ├─ app.php @@ -142,7 +150,7 @@ that follows these best practices: .. code-block:: bash - $ php app/console generate:bundle --namespace=AppBundle --dir=src --format=annotation --no-interaction + $ php bin/console generate:bundle --namespace=AppBundle --dir=src --format=annotation --no-interaction Extending the Directory Structure --------------------------------- @@ -152,27 +160,6 @@ structure of Symfony, you can :doc:`override the location of the main directories `: ``cache/``, ``logs/`` and ``web/``. -In addition, Symfony3 will use a slightly different directory structure when -it's released: - -.. code-block:: text - - blog-symfony3/ - ├─ app/ - │ ├─ config/ - │ └─ Resources/ - ├─ bin/ - │ └─ console - ├─ src/ - ├─ var/ - │ ├─ cache/ - │ └─ logs/ - ├─ vendor/ - └─ web/ - -The changes are pretty superficial, but for now, we recommend that you use -the Symfony directory structure. - .. _`Composer`: https://getcomposer.org/ .. _`Get Started`: https://getcomposer.org/doc/00-intro.md .. _`Composer download page`: https://getcomposer.org/download/ diff --git a/best_practices/introduction.rst b/best_practices/introduction.rst index 2c5661c6671..dad135249e6 100644 --- a/best_practices/introduction.rst +++ b/best_practices/introduction.rst @@ -76,12 +76,8 @@ installer and then execute this command to download the demo application: .. code-block:: bash - # Linux and Mac OS X $ symfony demo - # Windows - c:\> php symfony demo - **The demo application is a simple blog engine**, because that will allow us to focus on the Symfony concepts and features without getting buried in difficult implementation details. Instead of developing the application step by step in diff --git a/best_practices/tests.rst b/best_practices/tests.rst index 758c7b567ce..16aa6d16a35 100644 --- a/best_practices/tests.rst +++ b/best_practices/tests.rst @@ -30,8 +30,8 @@ A functional test can be as easy as this: .. code-block:: php - // src/AppBundle/Tests/ApplicationAvailabilityFunctionalTest.php - namespace AppBundle\Tests; + // tests/AppBundle/ApplicationAvailabilityFunctionalTest.php + namespace Tests\AppBundle; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; From c6d436b30412abe3c6d914c4de322670f4f46ecb Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 11:06:28 +0100 Subject: [PATCH 17/41] [QuickTour] Use new directory structure --- quick_tour/the_architecture.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/quick_tour/the_architecture.rst b/quick_tour/the_architecture.rst index e9b9816fc21..a345807af66 100644 --- a/quick_tour/the_architecture.rst +++ b/quick_tour/the_architecture.rst @@ -15,8 +15,14 @@ but the recommended structure is as follows: ``app/`` The application configuration, templates and translations. +``bin/`` + Executable files (e.g. ``bin/console``). ``src/`` The project's PHP code. +``tests/`` + Automatic tests (e.g. Unit tests). +``var/`` + Generated files (cache, logs, etc.). ``vendor/`` The third-party dependencies. ``web/`` @@ -30,7 +36,7 @@ stylesheets and JavaScript files. It is also where each :term:`front controller` lives, such as the production controller shown here:: // web/app.php - require_once __DIR__.'/../app/bootstrap.php.cache'; + require_once __DIR__.'/../var/bootstrap.php.cache'; require_once __DIR__.'/../app/AppKernel.php'; use Symfony\Component\HttpFoundation\Request; @@ -260,7 +266,7 @@ Symfony applications can contain several configuration files defined in several formats (YAML, XML, PHP, etc.) Instead of parsing and combining all those files for each request, Symfony uses its own cache system. In fact, the application configuration is only parsed for the very first request -and then compiled down to plain PHP code stored in the ``app/cache/`` +and then compiled down to plain PHP code stored in the ``var/cache/`` directory. In the development environment, Symfony is smart enough to update the cache @@ -271,10 +277,10 @@ the ``prod`` environment: .. code-block:: bash - $ php app/console cache:clear --env=prod + $ php bin/console cache:clear --env=prod When developing a web application, things can go wrong in many ways. The -log files in the ``app/logs/`` directory tell you everything about the requests +log files in the ``var/logs/`` directory tell you everything about the requests and help you fix the problem quickly. Using the Command Line Interface @@ -288,13 +294,13 @@ Run it without any arguments to learn more about its capabilities: .. code-block:: bash - $ php app/console + $ php bin/console The ``--help`` option helps you discover the usage of a command: .. code-block:: bash - $ php app/console debug:router --help + $ php bin/console debug:router --help Final Thoughts -------------- From bea4a0c9d7162acc7bd655a4279dc06b06f063f9 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 11:11:26 +0100 Subject: [PATCH 18/41] app/console -> bin/console --- cookbook/assetic/asset_management.rst | 6 +++--- cookbook/bundles/installation.rst | 4 ++-- cookbook/configuration/apache_router.rst | 2 +- cookbook/configuration/environments.rst | 6 +++--- .../front_controllers_and_kernel.rst | 4 ++-- .../configuration/override_dir_structure.rst | 4 ++-- cookbook/console/console_command.rst | 2 +- cookbook/console/usage.rst | 6 +++--- cookbook/deployment/azure-website.rst | 2 +- cookbook/deployment/heroku.rst | 2 +- cookbook/deployment/platformsh.rst | 4 ++-- cookbook/deployment/tools.rst | 4 ++-- cookbook/doctrine/console.rst | 6 +++--- .../doctrine/multiple_entity_managers.rst | 8 ++++---- cookbook/doctrine/registration_form.rst | 2 +- cookbook/doctrine/reverse_engineering.rst | 6 +++--- cookbook/email/spool.rst | 6 +++--- cookbook/event_dispatcher/event_listener.rst | 4 ++-- cookbook/profiler/profiling_data.rst | 6 +++--- cookbook/security/acl.rst | 2 +- cookbook/security/entity_provider.rst | 4 ++-- cookbook/web_server/built_in.rst | 20 +++++++++---------- 22 files changed, 55 insertions(+), 55 deletions(-) diff --git a/cookbook/assetic/asset_management.rst b/cookbook/assetic/asset_management.rst index af0055f5795..2972243e842 100644 --- a/cookbook/assetic/asset_management.rst +++ b/cookbook/assetic/asset_management.rst @@ -500,7 +500,7 @@ each time you deploy), you should run the following command: .. code-block:: bash - $ php app/console assetic:dump --env=prod --no-debug + $ php bin/console assetic:dump --env=prod --no-debug This will physically generate and write each file that you need (e.g. ``/js/abcd123.js``). If you update any of your assets, you'll need to run this again to regenerate @@ -542,7 +542,7 @@ need to dump them manually. To do so, run the following command: .. code-block:: bash - $ php app/console assetic:dump + $ php bin/console assetic:dump This physically writes all of the asset files you need for your ``dev`` environment. The big disadvantage is that you need to run this each time @@ -551,7 +551,7 @@ assets will be regenerated automatically *as they change*: .. code-block:: bash - $ php app/console assetic:watch + $ php bin/console assetic:watch The ``assetic:watch`` command was introduced in AsseticBundle 2.4. In prior versions, you had to use the ``--watch`` option of the ``assetic:dump`` diff --git a/cookbook/bundles/installation.rst b/cookbook/bundles/installation.rst index 1dd7e1f4d83..2b6f222fd57 100644 --- a/cookbook/bundles/installation.rst +++ b/cookbook/bundles/installation.rst @@ -108,14 +108,14 @@ via the ``config:dump-reference`` command: .. code-block:: bash - $ app/console config:dump-reference AsseticBundle + $ bin/console config:dump-reference AsseticBundle Instead of the full bundle name, you can also pass the short name used as the root of the bundle's configuration: .. code-block:: bash - $ app/console config:dump-reference assetic + $ bin/console config:dump-reference assetic The output will look like this: diff --git a/cookbook/configuration/apache_router.rst b/cookbook/configuration/apache_router.rst index a8b4f8a7c33..c42ed3dd818 100644 --- a/cookbook/configuration/apache_router.rst +++ b/cookbook/configuration/apache_router.rst @@ -98,7 +98,7 @@ Now generate the mod_rewrite rules: .. code-block:: bash - $ php app/console router:dump-apache -e=prod --no-debug + $ php bin/console router:dump-apache -e=prod --no-debug Which should roughly output the following: diff --git a/cookbook/configuration/environments.rst b/cookbook/configuration/environments.rst index a7b3ac22ba3..8bb2c45a41b 100644 --- a/cookbook/configuration/environments.rst +++ b/cookbook/configuration/environments.rst @@ -221,13 +221,13 @@ behavior: .. code-block:: bash # 'dev' environment and debug enabled - $ php app/console command_name + $ php bin/console command_name # 'prod' environment (debug is always disabled for 'prod') - $ php app/console command_name --env=prod + $ php bin/console command_name --env=prod # 'test' environment and debug disabled - $ php app/console command_name --env=test --no-debug + $ php bin/console command_name --env=test --no-debug In addition to the ``--env`` and ``--debug`` options, the behavior of Symfony commands can also be controlled with environment variables. The Symfony console diff --git a/cookbook/configuration/front_controllers_and_kernel.rst b/cookbook/configuration/front_controllers_and_kernel.rst index cab5f41b427..9bfe3be4e46 100644 --- a/cookbook/configuration/front_controllers_and_kernel.rst +++ b/cookbook/configuration/front_controllers_and_kernel.rst @@ -75,7 +75,7 @@ as the default one. access. For example, you don't want to make a debugging environment available to arbitrary users in your production environment. -Technically, the `app/console`_ script used when running Symfony on the command +Technically, the `bin/console`_ script used when running Symfony on the command line is also a front controller, only that is not used for web, but for command line requests. @@ -162,7 +162,7 @@ way of loading your configuration. .. _Symfony Standard Edition: https://github.com/symfony/symfony-standard .. _app.php: https://github.com/symfony/symfony-standard/blob/master/web/app.php .. _app_dev.php: https://github.com/symfony/symfony-standard/blob/master/web/app_dev.php -.. _app/console: https://github.com/symfony/symfony-standard/blob/master/app/console +.. _bin/console: https://github.com/symfony/symfony-standard/blob/master/bin/console .. _AppKernel: https://github.com/symfony/symfony-standard/blob/master/app/AppKernel.php .. _decorate: https://en.wikipedia.org/wiki/Decorator_pattern .. _RewriteRule shipped with the Symfony Standard Edition: https://github.com/symfony/symfony-standard/blob/master/web/.htaccess diff --git a/cookbook/configuration/override_dir_structure.rst b/cookbook/configuration/override_dir_structure.rst index d387a7931fa..6a6bc5f1bf4 100644 --- a/cookbook/configuration/override_dir_structure.rst +++ b/cookbook/configuration/override_dir_structure.rst @@ -154,8 +154,8 @@ file: .. code-block:: bash - $ php app/console cache:clear --env=prod - $ php app/console assetic:dump --env=prod --no-debug + $ php bin/console cache:clear --env=prod + $ php bin/console assetic:dump --env=prod --no-debug Override the ``vendor`` Directory --------------------------------- diff --git a/cookbook/console/console_command.rst b/cookbook/console/console_command.rst index 7e23a4762a4..2069aaa361b 100644 --- a/cookbook/console/console_command.rst +++ b/cookbook/console/console_command.rst @@ -68,7 +68,7 @@ This command will now automatically be available to run: .. code-block:: bash - $ php app/console demo:greet Fabien + $ php bin/console demo:greet Fabien .. _cookbook-console-dic: diff --git a/cookbook/console/usage.rst b/cookbook/console/usage.rst index 0e2c1e5befd..8bdd134913e 100644 --- a/cookbook/console/usage.rst +++ b/cookbook/console/usage.rst @@ -17,13 +17,13 @@ clear and warm the ``prod`` cache you need to run: .. code-block:: bash - $ php app/console cache:clear --env=prod + $ php bin/console cache:clear --env=prod or the equivalent: .. code-block:: bash - $ php app/console cache:clear -e prod + $ php bin/console cache:clear -e prod In addition to changing the environment, you can also choose to disable debug mode. This can be useful where you want to run commands in the ``dev`` environment @@ -31,4 +31,4 @@ but avoid the performance hit of collecting debug data: .. code-block:: bash - $ php app/console list --no-debug + $ php bin/console list --no-debug diff --git a/cookbook/deployment/azure-website.rst b/cookbook/deployment/azure-website.rst index e24ed31409e..3ec53c8e466 100644 --- a/cookbook/deployment/azure-website.rst +++ b/cookbook/deployment/azure-website.rst @@ -388,7 +388,7 @@ MySQL database. .. code-block:: bash - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force This command builds the tables and indexes for your MySQL database. If your Symfony application is more complex than a basic Symfony Standard Edition, you diff --git a/cookbook/deployment/heroku.rst b/cookbook/deployment/heroku.rst index 62ca1be4365..b61c923c891 100644 --- a/cookbook/deployment/heroku.rst +++ b/cookbook/deployment/heroku.rst @@ -275,7 +275,7 @@ This is also very useful to build assets on the production system, e.g. with Ass { "scripts": { "compile": [ - "app/console assetic:dump" + "bin/console assetic:dump" ] } } diff --git a/cookbook/deployment/platformsh.rst b/cookbook/deployment/platformsh.rst index 7b679177feb..c4d91aafef8 100644 --- a/cookbook/deployment/platformsh.rst +++ b/cookbook/deployment/platformsh.rst @@ -69,9 +69,9 @@ Platform.sh how to deploy your application (read more about hooks: build: | rm web/app_dev.php - app/console --env=prod assetic:dump --no-debug + bin/console --env=prod assetic:dump --no-debug deploy: | - app/console --env=prod cache:clear + bin/console --env=prod cache:clear For best practices, you should also add a ``.platform`` folder at the root of your Git repository which contains the following files: diff --git a/cookbook/deployment/tools.rst b/cookbook/deployment/tools.rst index c53ed2fa6a5..cf6c3186e1f 100644 --- a/cookbook/deployment/tools.rst +++ b/cookbook/deployment/tools.rst @@ -150,7 +150,7 @@ Make sure you clear (and warm-up) your Symfony cache: .. code-block:: bash - $ php app/console cache:clear --env=prod --no-debug + $ php bin/console cache:clear --env=prod --no-debug E) Dump your Assetic Assets ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -159,7 +159,7 @@ If you're using Assetic, you'll also want to dump your assets: .. code-block:: bash - $ php app/console assetic:dump --env=prod --no-debug + $ php bin/console assetic:dump --env=prod --no-debug F) Other Things! ~~~~~~~~~~~~~~~~ diff --git a/cookbook/doctrine/console.rst b/cookbook/doctrine/console.rst index 0cfb7befca0..11459a3b2d5 100644 --- a/cookbook/doctrine/console.rst +++ b/cookbook/doctrine/console.rst @@ -11,7 +11,7 @@ command: .. code-block:: bash - $ php app/console list doctrine + $ php bin/console list doctrine A list of available commands will print out. You can find out more information about any of these commands (or any Symfony command) by running the ``help`` @@ -20,7 +20,7 @@ task, run: .. code-block:: bash - $ php app/console help doctrine:database:create + $ php bin/console help doctrine:database:create Some notable or interesting tasks include: @@ -30,7 +30,7 @@ Some notable or interesting tasks include: .. code-block:: bash - $ php app/console doctrine:ensure-production-settings --env=prod + $ php bin/console doctrine:ensure-production-settings --env=prod * ``doctrine:mapping:import`` - allows Doctrine to introspect an existing database and create mapping information. For more information, see diff --git a/cookbook/doctrine/multiple_entity_managers.rst b/cookbook/doctrine/multiple_entity_managers.rst index 5434d847365..484809aad4c 100644 --- a/cookbook/doctrine/multiple_entity_managers.rst +++ b/cookbook/doctrine/multiple_entity_managers.rst @@ -165,20 +165,20 @@ When working with multiple connections to create your databases: .. code-block:: bash # Play only with "default" connection - $ php app/console doctrine:database:create + $ php bin/console doctrine:database:create # Play only with "customer" connection - $ php app/console doctrine:database:create --connection=customer + $ php bin/console doctrine:database:create --connection=customer When working with multiple entity managers to update your schema: .. code-block:: bash # Play only with "default" mappings - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force # Play only with "customer" mappings - $ php app/console doctrine:schema:update --force --em=customer + $ php bin/console doctrine:schema:update --force --em=customer If you *do* omit the entity manager's name when asking for it, the default entity manager (i.e. ``default``) is returned:: diff --git a/cookbook/doctrine/registration_form.rst b/cookbook/doctrine/registration_form.rst index 062969242c1..9e31f9eded9 100644 --- a/cookbook/doctrine/registration_form.rst +++ b/cookbook/doctrine/registration_form.rst @@ -322,7 +322,7 @@ database schema using this command: .. code-block:: bash - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force That's it! Head to ``/register`` to try things out! diff --git a/cookbook/doctrine/reverse_engineering.rst b/cookbook/doctrine/reverse_engineering.rst index dd50a6be9c2..efa393a0beb 100644 --- a/cookbook/doctrine/reverse_engineering.rst +++ b/cookbook/doctrine/reverse_engineering.rst @@ -59,7 +59,7 @@ table fields. .. code-block:: bash - $ php app/console doctrine:mapping:import --force AcmeBlogBundle xml + $ php bin/console doctrine:mapping:import --force AcmeBlogBundle xml This command line tool asks Doctrine to introspect the database and generate the XML metadata files under the ``src/Acme/BlogBundle/Resources/config/doctrine`` @@ -92,8 +92,8 @@ entity classes by executing the following two commands. .. code-block:: bash - $ php app/console doctrine:mapping:convert annotation ./src - $ php app/console doctrine:generate:entities AcmeBlogBundle + $ php bin/console doctrine:mapping:convert annotation ./src + $ php bin/console doctrine:generate:entities AcmeBlogBundle The first command generates entity classes with annotation mappings. But if you want to use YAML or XML mapping instead of annotations, you should diff --git a/cookbook/email/spool.rst b/cookbook/email/spool.rst index 3747f421f81..d8b897c9619 100644 --- a/cookbook/email/spool.rst +++ b/cookbook/email/spool.rst @@ -117,19 +117,19 @@ There is a console command to send the messages in the spool: .. code-block:: bash - $ php app/console swiftmailer:spool:send --env=prod + $ php bin/console swiftmailer:spool:send --env=prod It has an option to limit the number of messages to be sent: .. code-block:: bash - $ php app/console swiftmailer:spool:send --message-limit=10 --env=prod + $ php bin/console swiftmailer:spool:send --message-limit=10 --env=prod You can also set the time limit in seconds: .. code-block:: bash - $ php app/console swiftmailer:spool:send --time-limit=10 --env=prod + $ php bin/console swiftmailer:spool:send --time-limit=10 --env=prod Of course you will not want to run this manually in reality. Instead, the console command should be triggered by a cron job or scheduled task and run diff --git a/cookbook/event_dispatcher/event_listener.rst b/cookbook/event_dispatcher/event_listener.rst index 19ceebf755f..ecdcada660b 100644 --- a/cookbook/event_dispatcher/event_listener.rst +++ b/cookbook/event_dispatcher/event_listener.rst @@ -274,11 +274,11 @@ using the console. To show all events and their listeners, run: .. code-block:: bash - $ php app/console debug:event-dispatcher + $ php bin/console debug:event-dispatcher You can get registered listeners for a particular event by specifying its name: .. code-block:: bash - $ php app/console debug:event-dispatcher kernel.exception + $ php bin/console debug:event-dispatcher kernel.exception diff --git a/cookbook/profiler/profiling_data.rst b/cookbook/profiler/profiling_data.rst index 761dae943e6..bb87bbf8cd7 100644 --- a/cookbook/profiler/profiling_data.rst +++ b/cookbook/profiler/profiling_data.rst @@ -53,10 +53,10 @@ one where the information was generated, use the ``profiler:export`` and .. code-block:: bash # on the production machine - $ php app/console profiler:export > profile.data + $ php bin/console profiler:export > profile.data # on the development machine - $ php app/console profiler:import /path/to/profile.data + $ php bin/console profiler:import /path/to/profile.data # you can also pipe from the STDIN - $ cat /path/to/profile.data | php app/console profiler:import + $ cat /path/to/profile.data | php bin/console profiler:import diff --git a/cookbook/security/acl.rst b/cookbook/security/acl.rst index b881393d91b..df3b936b3f0 100644 --- a/cookbook/security/acl.rst +++ b/cookbook/security/acl.rst @@ -96,7 +96,7 @@ Fortunately, there is a task for this. Simply run the following command: .. code-block:: bash - $ php app/console init:acl + $ php bin/console init:acl Getting Started --------------- diff --git a/cookbook/security/entity_provider.rst b/cookbook/security/entity_provider.rst index 58acf646245..1cb4db24bd3 100644 --- a/cookbook/security/entity_provider.rst +++ b/cookbook/security/entity_provider.rst @@ -145,13 +145,13 @@ by running: .. code-block:: bash - $ php app/console doctrine:generate:entities AppBundle/Entity/User + $ php bin/console doctrine:generate:entities AppBundle/Entity/User Next, make sure to :ref:`create the database table `: .. code-block:: bash - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force What's this UserInterface? ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/cookbook/web_server/built_in.rst b/cookbook/web_server/built_in.rst index dc42eda9cb9..10dceab5b4e 100644 --- a/cookbook/web_server/built_in.rst +++ b/cookbook/web_server/built_in.rst @@ -27,7 +27,7 @@ executing the ``server:start`` command: .. code-block:: bash - $ php app/console server:start + $ php bin/console server:start This starts the web server at ``localhost:8000`` in the background that serves your Symfony application. @@ -37,7 +37,7 @@ can change the socket passing an IP address and a port as a command-line argumen .. code-block:: bash - $ php app/console server:start 192.168.0.1:8080 + $ php bin/console server:start 192.168.0.1:8080 .. note:: @@ -46,7 +46,7 @@ can change the socket passing an IP address and a port as a command-line argumen .. code-block:: bash - $ php app/console server:start --force + $ php bin/console server:start --force .. versionadded:: 2.8 The ``--force`` option was introduced in Symfony 2.8. @@ -58,9 +58,9 @@ can change the socket passing an IP address and a port as a command-line argumen .. code-block:: bash - $ php app/console server:status + $ php bin/console server:status - $ php app/console server:status 192.168.0.1:8080 + $ php bin/console server:status 192.168.0.1:8080 The first command shows if your Symfony application will be server through ``localhost:8000``, the second one does the same for ``192.168.0.1:8080``. @@ -82,7 +82,7 @@ can change the socket passing an IP address and a port as a command-line argumen .. code-block:: bash - $ php app/console server:start 0.0.0.0:8000 + $ php bin/console server:start 0.0.0.0:8000 .. caution:: @@ -101,14 +101,14 @@ script: .. code-block:: bash - $ php app/console server:start --env=test --router=app/config/router_test.php + $ php bin/console server:start --env=test --router=app/config/router_test.php If your application's document root differs from the standard directory layout, you have to pass the correct location using the ``--docroot`` option: .. code-block:: bash - $ php app/console server:start --docroot=public_html + $ php bin/console server:start --docroot=public_html Stopping the Server ------------------- @@ -118,7 +118,7 @@ command: .. code-block:: bash - $ php app/console server:stop + $ php bin/console server:stop Like with the start command, if you omit the socket information, Symfony will stop the web server bound to ``localhost:8000``. Just pass the socket information @@ -126,7 +126,7 @@ when the web server listens to another IP address or to another port: .. code-block:: bash - $ php app/console server:stop 192.168.0.1:8080 + $ php bin/console server:stop 192.168.0.1:8080 .. _`built-in web server`: http://www.php.net/manual/en/features.commandline.webserver.php .. _`php.net`: http://php.net/manual/en/features.commandline.webserver.php#example-411 From b6d93f09bf5d26bd4f9be965b23b659cbe00f3e1 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 11:12:36 +0100 Subject: [PATCH 19/41] app/phpunit.xml.dist -> phpunit.xml.dist --- cookbook/testing/bootstrap.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cookbook/testing/bootstrap.rst b/cookbook/testing/bootstrap.rst index aecbaff6c94..1f3c5464e41 100644 --- a/cookbook/testing/bootstrap.rst +++ b/cookbook/testing/bootstrap.rst @@ -19,12 +19,12 @@ First, add the following file:: require __DIR__.'/bootstrap.php.cache'; -Replace the test bootstrap file ``bootstrap.php.cache`` in ``app/phpunit.xml.dist`` +Replace the test bootstrap file ``bootstrap.php.cache`` in ``phpunit.xml.dist`` with ``tests.bootstrap.php``: .. code-block:: xml - + + From b3da3b7e19e5f85959b10b590487f575e1139fad Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 11:14:00 +0100 Subject: [PATCH 20/41] app/cache -> var/cache --- cookbook/configuration/environments.rst | 6 +++--- cookbook/deployment/azure-website.rst | 4 ++-- cookbook/deployment/platformsh.rst | 2 +- cookbook/workflow/new_project_svn.rst | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cookbook/configuration/environments.rst b/cookbook/configuration/environments.rst index 8bb2c45a41b..15f2e2f8479 100644 --- a/cookbook/configuration/environments.rst +++ b/cookbook/configuration/environments.rst @@ -342,13 +342,13 @@ Symfony takes advantage of caching in many ways: the application configuration, routing configuration, Twig templates and more are cached to PHP objects stored in files on the filesystem. -By default, these cached files are largely stored in the ``app/cache`` directory. +By default, these cached files are largely stored in the ``var/cache`` directory. However, each environment caches its own set of files: .. code-block:: text / - ├─ app/ + ├─ var/ │ ├─ cache/ │ │ ├─ dev/ # cache directory for the *dev* environment │ │ └─ prod/ # cache directory for the *prod* environment @@ -357,7 +357,7 @@ However, each environment caches its own set of files: Sometimes, when debugging, it may be helpful to inspect a cached file to understand how something is working. When doing so, remember to look in the directory of the environment you're using (most commonly ``dev`` while -developing and debugging). While it can vary, the ``app/cache/dev`` directory +developing and debugging). While it can vary, the ``var/cache/dev`` directory includes the following: ``appDevDebugProjectContainer.php`` diff --git a/cookbook/deployment/azure-website.rst b/cookbook/deployment/azure-website.rst index 3ec53c8e466..a1c8307871a 100644 --- a/cookbook/deployment/azure-website.rst +++ b/cookbook/deployment/azure-website.rst @@ -260,10 +260,10 @@ directory with at least the following contents: .. code-block:: text /app/bootstrap.php.cache - /app/cache/* + /var/cache/* /app/config/parameters.yml /app/logs/* - !app/cache/.gitkeep + !var/cache/.gitkeep !app/logs/.gitkeep /app/SymfonyRequirements.php /build/ diff --git a/cookbook/deployment/platformsh.rst b/cookbook/deployment/platformsh.rst index c4d91aafef8..9ca118f197e 100644 --- a/cookbook/deployment/platformsh.rst +++ b/cookbook/deployment/platformsh.rst @@ -62,7 +62,7 @@ Platform.sh how to deploy your application (read more about # The mounts that will be performed when the package is deployed. mounts: - "/app/cache": "shared:files/cache" + "/var/cache": "shared:files/cache" "/app/logs": "shared:files/logs" # The hooks that will be performed when the package is deployed. diff --git a/cookbook/workflow/new_project_svn.rst b/cookbook/workflow/new_project_svn.rst index 8fe7e9eacd9..9ea1c05b78a 100644 --- a/cookbook/workflow/new_project_svn.rst +++ b/cookbook/workflow/new_project_svn.rst @@ -75,17 +75,17 @@ with these steps: .. code-block:: bash $ cd myproject/ - $ svn add --depth=empty app app/cache app/logs app/config web + $ svn add --depth=empty app var/cache app/logs app/config web $ svn propset svn:ignore "vendor" . $ svn propset svn:ignore "bootstrap*" app/ $ svn propset svn:ignore "parameters.yml" app/config/ - $ svn propset svn:ignore "*" app/cache/ + $ svn propset svn:ignore "*" var/cache/ $ svn propset svn:ignore "*" app/logs/ $ svn propset svn:ignore "bundles" web - $ svn ci -m "commit basic Symfony ignore list (vendor, app/bootstrap*, app/config/parameters.yml, app/cache/*, app/logs/*, web/bundles)" + $ svn ci -m "commit basic Symfony ignore list (vendor, app/bootstrap*, app/config/parameters.yml, var/cache/*, app/logs/*, web/bundles)" #. The rest of the files can now be added and committed to the project: From 6614c0f8def8555165b2a5b3aa64cac15deab64d Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 11:14:54 +0100 Subject: [PATCH 21/41] app/logs -> var/logs --- cookbook/console/logging.rst | 2 +- cookbook/deployment/azure-website.rst | 4 ++-- cookbook/logging/monolog.rst | 4 ++-- cookbook/workflow/new_project_svn.rst | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cookbook/console/logging.rst b/cookbook/console/logging.rst index 08781d7901b..4b2c83a0c6d 100644 --- a/cookbook/console/logging.rst +++ b/cookbook/console/logging.rst @@ -65,7 +65,7 @@ container and use it to do the logging:: } Depending on the environment in which you run your command (and your logging -setup), you should see the logged entries in ``app/logs/dev.log`` or ``app/logs/prod.log``. +setup), you should see the logged entries in ``var/logs/dev.log`` or ``var/logs/prod.log``. Enabling automatic Exceptions Logging ------------------------------------- diff --git a/cookbook/deployment/azure-website.rst b/cookbook/deployment/azure-website.rst index a1c8307871a..93a2661ce2a 100644 --- a/cookbook/deployment/azure-website.rst +++ b/cookbook/deployment/azure-website.rst @@ -262,9 +262,9 @@ directory with at least the following contents: /app/bootstrap.php.cache /var/cache/* /app/config/parameters.yml - /app/logs/* + /var/logs/* !var/cache/.gitkeep - !app/logs/.gitkeep + !var/logs/.gitkeep /app/SymfonyRequirements.php /build/ /vendor/ diff --git a/cookbook/logging/monolog.rst b/cookbook/logging/monolog.rst index 28db626cda6..c4e5c3d9a7f 100644 --- a/cookbook/logging/monolog.rst +++ b/cookbook/logging/monolog.rst @@ -39,8 +39,8 @@ to write the logs (the handlers can be shared). the logger will log to. The basic handler is the ``StreamHandler`` which writes logs in a stream -(by default in the ``app/logs/prod.log`` in the prod environment and -``app/logs/dev.log`` in the dev environment). +(by default in the ``var/logs/prod.log`` in the prod environment and +``var/logs/dev.log`` in the dev environment). Monolog comes also with a powerful built-in handler for the logging in prod environment: ``FingersCrossedHandler``. It allows you to store the diff --git a/cookbook/workflow/new_project_svn.rst b/cookbook/workflow/new_project_svn.rst index 9ea1c05b78a..3bf786d7f9f 100644 --- a/cookbook/workflow/new_project_svn.rst +++ b/cookbook/workflow/new_project_svn.rst @@ -75,17 +75,17 @@ with these steps: .. code-block:: bash $ cd myproject/ - $ svn add --depth=empty app var/cache app/logs app/config web + $ svn add --depth=empty app var/cache var/logs app/config web $ svn propset svn:ignore "vendor" . $ svn propset svn:ignore "bootstrap*" app/ $ svn propset svn:ignore "parameters.yml" app/config/ $ svn propset svn:ignore "*" var/cache/ - $ svn propset svn:ignore "*" app/logs/ + $ svn propset svn:ignore "*" var/logs/ $ svn propset svn:ignore "bundles" web - $ svn ci -m "commit basic Symfony ignore list (vendor, app/bootstrap*, app/config/parameters.yml, var/cache/*, app/logs/*, web/bundles)" + $ svn ci -m "commit basic Symfony ignore list (vendor, app/bootstrap*, app/config/parameters.yml, var/cache/*, var/logs/*, web/bundles)" #. The rest of the files can now be added and committed to the project: From af7052b63e7d562df3d990e2fb3165d3d3c04ff0 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 11:45:07 +0100 Subject: [PATCH 22/41] app/bootstrap.php.cache -> var/bootstrap.php.cache --- cookbook/configuration/apache_router.rst | 2 +- cookbook/configuration/override_dir_structure.rst | 3 +-- cookbook/debugging.rst | 13 ++++++------- cookbook/workflow/new_project_svn.rst | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cookbook/configuration/apache_router.rst b/cookbook/configuration/apache_router.rst index c42ed3dd818..4e69b18a289 100644 --- a/cookbook/configuration/apache_router.rst +++ b/cookbook/configuration/apache_router.rst @@ -145,7 +145,7 @@ to ``ApacheRequest`` in ``web/app.php``:: // web/app.php - require_once __DIR__.'/../app/bootstrap.php.cache'; + require_once __DIR__.'/../var/bootstrap.php.cache'; require_once __DIR__.'/../app/AppKernel.php'; // require_once __DIR__.'/../app/AppCache.php'; diff --git a/cookbook/configuration/override_dir_structure.rst b/cookbook/configuration/override_dir_structure.rst index 6a6bc5f1bf4..7b552fc8f3a 100644 --- a/cookbook/configuration/override_dir_structure.rst +++ b/cookbook/configuration/override_dir_structure.rst @@ -91,8 +91,7 @@ in your ``app.php`` and ``app_dev.php`` front controllers. If you simply renamed the directory, you're fine. But if you moved it in some way, you may need to modify these paths inside those files:: - require_once __DIR__.'/../Symfony/app/bootstrap.php.cache'; - require_once __DIR__.'/../Symfony/app/AppKernel.php'; + require_once __DIR__.'/../Symfony/var/bootstrap.php.cache'; You also need to change the ``extra.symfony-web-dir`` option in the ``composer.json`` file: diff --git a/cookbook/debugging.rst b/cookbook/debugging.rst index 98fae25bad8..2333bd65665 100644 --- a/cookbook/debugging.rst +++ b/cookbook/debugging.rst @@ -30,22 +30,21 @@ The ``app_dev.php`` front controller reads as follows by default:: // ... - $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; - require_once __DIR__.'/../app/AppKernel.php'; + $loader = require __DIR__.'/../app/autoload.php'; + Debug::enable(); $kernel = new AppKernel('dev', true); $kernel->loadClassCache(); $request = Request::createFromGlobals(); + // ... -To make your debugger happier, disable all PHP class caches by removing the -call to ``loadClassCache()`` and by replacing the require statements like -below:: +To make your debugger happier, disable all PHP class caches by removing (or +commenting) the call to ``loadClassCache()``:: // ... - // $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; $loader = require_once __DIR__.'/../app/autoload.php'; - require_once __DIR__.'/../app/AppKernel.php'; + Debug::enable(); $kernel = new AppKernel('dev', true); // $kernel->loadClassCache(); diff --git a/cookbook/workflow/new_project_svn.rst b/cookbook/workflow/new_project_svn.rst index 3bf786d7f9f..7cec932445d 100644 --- a/cookbook/workflow/new_project_svn.rst +++ b/cookbook/workflow/new_project_svn.rst @@ -78,14 +78,14 @@ with these steps: $ svn add --depth=empty app var/cache var/logs app/config web $ svn propset svn:ignore "vendor" . - $ svn propset svn:ignore "bootstrap*" app/ + $ svn propset svn:ignore "bootstrap*" var/ $ svn propset svn:ignore "parameters.yml" app/config/ $ svn propset svn:ignore "*" var/cache/ $ svn propset svn:ignore "*" var/logs/ $ svn propset svn:ignore "bundles" web - $ svn ci -m "commit basic Symfony ignore list (vendor, app/bootstrap*, app/config/parameters.yml, var/cache/*, var/logs/*, web/bundles)" + $ svn ci -m "commit basic Symfony ignore list (vendor, var/bootstrap*, app/config/parameters.yml, var/cache/*, var/logs/*, web/bundles)" #. The rest of the files can now be added and committed to the project: From ef613f6ed71fef442ef52fe72a26faaea87f5f15 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 11:45:37 +0100 Subject: [PATCH 23/41] app/SymfonyRequirements.php -> bin/SymfonyRequirements.php --- cookbook/deployment/azure-website.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/deployment/azure-website.rst b/cookbook/deployment/azure-website.rst index 93a2661ce2a..ba5e278b2d1 100644 --- a/cookbook/deployment/azure-website.rst +++ b/cookbook/deployment/azure-website.rst @@ -265,7 +265,7 @@ directory with at least the following contents: /var/logs/* !var/cache/.gitkeep !var/logs/.gitkeep - /app/SymfonyRequirements.php + /bin/SymfonyRequirements.php /build/ /vendor/ /bin/ From df20095156a9c82d766f6c8310dd8763d921c730 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 11:54:54 +0100 Subject: [PATCH 24/41] Testing changes --- cookbook/email/testing.rst | 4 ++- cookbook/form/unit_testing.rst | 26 ++++++++++--------- cookbook/testing/database.rst | 13 +++++++--- cookbook/testing/doctrine.rst | 11 ++++---- cookbook/testing/profiling.rst | 6 ++--- .../testing/simulating_authentication.rst | 4 +-- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/cookbook/email/testing.rst b/cookbook/email/testing.rst index 270f7506895..6ab1e522e7e 100644 --- a/cookbook/email/testing.rst +++ b/cookbook/email/testing.rst @@ -33,7 +33,9 @@ Start with an easy controller action that sends an email:: In your functional test, use the ``swiftmailer`` collector on the profiler to get information about the messages sent on the previous request:: - // src/AppBundle/Tests/Controller/MailControllerTest.php + // tests/AppBundle/Controller/MailControllerTest.php + namespace Tests\AppBundle\Controller; + use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class MailControllerTest extends WebTestCase diff --git a/cookbook/form/unit_testing.rst b/cookbook/form/unit_testing.rst index e27d944cb7e..3a082dfd49f 100644 --- a/cookbook/form/unit_testing.rst +++ b/cookbook/form/unit_testing.rst @@ -36,8 +36,8 @@ The Basics The simplest ``TypeTestCase`` implementation looks like the following:: - // src/AppBundle/Tests/Form/Type/TestedTypeTest.php - namespace AppBundle\Tests\Form\Type; + // tests/AppBundle/Form/Type/TestedTypeTest.php + namespace Tests\AppBundle\Form\Type; use AppBundle\Form\Type\TestedType; use AppBundle\Model\TestObject; @@ -117,15 +117,18 @@ might look like this:: // src/AppBundle/Form/Type/TestedType.php - // ... the buildForm method - $builder->add('app_test_child_type'); + // ... + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('app_test_child_type'); + } To create your form correctly, you need to make the type available to the form factory in your test. The easiest way is to register it manually before creating the parent form using the ``PreloadedExtension`` class:: - // src/AppBundle/Tests/Form/Type/TestedTypeTests.php - namespace AppBundle\Tests\Form\Type; + // tests/AppBundle/Form/Type/TestedTypeTests.php + namespace Tests\AppBundle\Form\Type; use AppBundle\Form\Type\TestedType; use AppBundle\Model\TestObject; @@ -158,7 +161,7 @@ before creating the parent form using the ``PreloadedExtension`` class:: be getting errors that are not related to the form you are currently testing but to its children. -Adding custom Extensions +Adding Custom Extensions ------------------------ It often happens that you use some options that are added by @@ -168,8 +171,8 @@ The ``TypeTestCase`` loads only the core form extension so an "Invalid option" exception will be raised if you try to use it for testing a class that depends on other extensions. You need to add those extensions to the factory object:: - // src/AppBundle/Tests/Form/Type/TestedTypeTests.php - namespace AppBundle\Tests\Form\Type; + // tests/AppBundle/Form/Type/TestedTypeTests.php + namespace Tests\AppBundle\Form\Type; use AppBundle\Form\Type\TestedType; use AppBundle\Model\TestObject; @@ -217,8 +220,8 @@ Testing against different Sets of Data If you are not familiar yet with PHPUnit's `data providers`_, this might be a good opportunity to use them:: - // src/AppBundle/Tests/Form/Type/TestedTypeTests.php - namespace AppBundle\Tests\Form\Type; + // tests/AppBundle/Form/Type/TestedTypeTests.php + namespace Tests\AppBundle\Form\Type; use AppBundle\Form\Type\TestedType; use AppBundle\Model\TestObject; @@ -226,7 +229,6 @@ a good opportunity to use them:: class TestedTypeTest extends TypeTestCase { - /** * @dataProvider getValidTestData */ diff --git a/cookbook/testing/database.rst b/cookbook/testing/database.rst index 04c8d07ee48..405a329f4e1 100644 --- a/cookbook/testing/database.rst +++ b/cookbook/testing/database.rst @@ -33,6 +33,7 @@ class. Suppose the class you want to test looks like this:: + // src/AppBundle/Salary/SalaryCalculator.php namespace AppBundle\Salary; use Doctrine\Common\Persistence\ObjectManager; @@ -59,14 +60,20 @@ Suppose the class you want to test looks like this:: Since the ``ObjectManager`` gets injected into the class through the constructor, it's easy to pass a mock object within a test:: + // tests/AppBundle/Salary/SalaryCalculatorTest.php + namespace Tests\AppBundle\Salary; + use AppBundle\Salary\SalaryCalculator; + use AppBundle\Entity\Employee; + use Doctrine\ORM\EntityRepository; + use Doctrine\Common\Persistence\ObjectManager; class SalaryCalculatorTest extends \PHPUnit_Framework_TestCase { public function testCalculateTotalSalary() { // First, mock the object to be used in the test - $employee = $this->getMock('\AppBundle\Entity\Employee'); + $employee = $this->getMock(Employee::class); $employee->expects($this->once()) ->method('getSalary') ->will($this->returnValue(1000)); @@ -76,7 +83,7 @@ it's easy to pass a mock object within a test:: // Now, mock the repository so it returns the mock of the employee $employeeRepository = $this - ->getMockBuilder('\Doctrine\ORM\EntityRepository') + ->getMockBuilder(EntityRepository::class) ->disableOriginalConstructor() ->getMock(); $employeeRepository->expects($this->once()) @@ -85,7 +92,7 @@ it's easy to pass a mock object within a test:: // Last, mock the EntityManager to return the mock of the repository $entityManager = $this - ->getMockBuilder('\Doctrine\Common\Persistence\ObjectManager') + ->getMockBuilder(ObjectManager::class) ->disableOriginalConstructor() ->getMock(); $entityManager->expects($this->once()) diff --git a/cookbook/testing/doctrine.rst b/cookbook/testing/doctrine.rst index c263d18c91c..aadbe729113 100644 --- a/cookbook/testing/doctrine.rst +++ b/cookbook/testing/doctrine.rst @@ -20,12 +20,12 @@ If you need to actually execute a query, you will need to boot the kernel to get a valid connection. In this case, you'll extend the ``KernelTestCase``, which makes all of this quite easy:: - // src/AppBundle/Tests/Entity/ProductRepositoryFunctionalTest.php - namespace AppBundle\Tests\Entity; + // tests/AppBundle/Entity/ProductRepositoryTest.php + namespace Tests\AppBundle\Entity; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; - class ProductRepositoryFunctionalTest extends KernelTestCase + class ProductRepositoryTest extends KernelTestCase { /** * @var \Doctrine\ORM\EntityManager @@ -38,10 +38,10 @@ which makes all of this quite easy:: public function setUp() { self::bootKernel(); + $this->em = static::$kernel->getContainer() ->get('doctrine') - ->getManager() - ; + ->getManager(); } public function testSearchByCategoryName() @@ -60,6 +60,7 @@ which makes all of this quite easy:: protected function tearDown() { parent::tearDown(); + $this->em->close(); } } diff --git a/cookbook/testing/profiling.rst b/cookbook/testing/profiling.rst index 1789c69dbc9..d809c4febe2 100644 --- a/cookbook/testing/profiling.rst +++ b/cookbook/testing/profiling.rst @@ -15,9 +15,9 @@ spent in the framework, etc. But before writing assertions, enable the profiler and check that the profiler is indeed available (it is enabled by default in the ``test`` environment):: - class HelloControllerTest extends WebTestCase + class LuckyControllerTest extends WebTestCase { - public function testIndex() + public function testNumberAction() { $client = static::createClient(); @@ -25,7 +25,7 @@ the ``test`` environment):: // (it does nothing if the profiler is not available) $client->enableProfiler(); - $crawler = $client->request('GET', '/hello/Fabien'); + $crawler = $client->request('GET', '/lucky/number'); // ... write some assertions about the Response diff --git a/cookbook/testing/simulating_authentication.rst b/cookbook/testing/simulating_authentication.rst index f2e04acd612..8777a67e2a1 100644 --- a/cookbook/testing/simulating_authentication.rst +++ b/cookbook/testing/simulating_authentication.rst @@ -15,8 +15,8 @@ Another way would be to create a token yourself and store it in a session. While doing this, you have to make sure that an appropriate cookie is sent with a request. The following example demonstrates this technique:: - // src/AppBundle/Tests/Controller/DefaultControllerTest.php - namespace Appbundle\Tests\Controller; + // tests/AppBundle/Controller/DefaultControllerTest.php + namespace Tests\Appbundle\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\BrowserKit\Cookie; From f2be12ab988d589c399011337de2bbbb50513e59 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 12:01:41 +0100 Subject: [PATCH 25/41] Updated directory structures --- .../configuration_organization.rst | 12 +++++-- cookbook/configuration/environments.rst | 2 +- .../configuration/override_dir_structure.rst | 35 +++++++++++-------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/cookbook/configuration/configuration_organization.rst b/cookbook/configuration/configuration_organization.rst index 5473a4c06b1..d6a5e4f1ade 100644 --- a/cookbook/configuration/configuration_organization.rst +++ b/cookbook/configuration/configuration_organization.rst @@ -34,7 +34,7 @@ default Symfony Standard Edition follow this structure: .. code-block:: text - / + your-project/ ├─ app/ │ └─ config/ │ ├─ config.yml @@ -47,6 +47,8 @@ default Symfony Standard Edition follow this structure: │ ├─ routing_dev.yml │ └─ security.yml ├─ src/ + ├─ tests/ + ├─ var/ ├─ vendor/ └─ web/ @@ -65,7 +67,7 @@ name as the environment: .. code-block:: text - / + your-project/ ├─ app/ │ └─ config/ │ ├─ common/ @@ -84,6 +86,8 @@ name as the environment: │ ├─ routing.yml │ └─ security.yml ├─ src/ + ├─ tests/ + ├─ var/ ├─ vendor/ └─ web/ @@ -161,7 +165,7 @@ and several files to define all application services: .. code-block:: text - / + your-project/ ├─ app/ │ └─ config/ │ ├─ bundles/ @@ -183,6 +187,8 @@ and several files to define all application services: │ ├─ ... │ └─ security.yml ├─ src/ + ├─ tests/ + ├─ var/ ├─ vendor/ └─ web/ diff --git a/cookbook/configuration/environments.rst b/cookbook/configuration/environments.rst index 15f2e2f8479..e43f07d6b46 100644 --- a/cookbook/configuration/environments.rst +++ b/cookbook/configuration/environments.rst @@ -347,7 +347,7 @@ However, each environment caches its own set of files: .. code-block:: text - / + your-project/ ├─ var/ │ ├─ cache/ │ │ ├─ dev/ # cache directory for the *dev* environment diff --git a/cookbook/configuration/override_dir_structure.rst b/cookbook/configuration/override_dir_structure.rst index 7b552fc8f3a..5982d2bf80e 100644 --- a/cookbook/configuration/override_dir_structure.rst +++ b/cookbook/configuration/override_dir_structure.rst @@ -12,12 +12,16 @@ directory structure is: your-project/ ├─ app/ - │ ├─ cache/ │ ├─ config/ - │ ├─ logs/ │ └─ ... ├─ src/ │ └─ ... + ├─ tests/ + │ └─ ... + ├─ var/ + │ ├─ cache/ + │ ├─ logs/ + │ └─ ... ├─ vendor/ │ └─ ... └─ web/ @@ -41,13 +45,13 @@ in the ``AppKernel`` class of you application:: public function getCacheDir() { - return $this->rootDir.'/'.$this->environment.'/cache'; + return dirname(__DIR__).'/var/'.$this->environment.'/cache'; } } -``$this->rootDir`` is the absolute path to the ``app`` directory and ``$this->environment`` -is the current environment (i.e. ``dev``). In this case you have changed -the location of the cache directory to ``app/{environment}/cache``. +In this code, ``$this->environment`` is the current environment (i.e. ``dev``). +In this case you have changed the location of the cache directory to +``var/{environment}/cache``. .. caution:: @@ -74,11 +78,11 @@ method:: public function getLogDir() { - return $this->rootDir.'/'.$this->environment.'/logs'; + return dirname(__DIR__).'/var/'.$this->environment.'/logs'; } } -Here you have changed the location of the directory to ``app/{environment}/logs``. +Here you have changed the location of the directory to ``var/{environment}/logs``. .. _override-web-dir: @@ -86,22 +90,22 @@ Override the ``web`` Directory ------------------------------ If you need to rename or move your ``web`` directory, the only thing you -need to guarantee is that the path to the ``app`` directory is still correct +need to guarantee is that the path to the ``var`` directory is still correct in your ``app.php`` and ``app_dev.php`` front controllers. If you simply renamed the directory, you're fine. But if you moved it in some way, you may need to modify these paths inside those files:: - require_once __DIR__.'/../Symfony/var/bootstrap.php.cache'; + require_once __DIR__.'/../path/to/var/bootstrap.php.cache'; -You also need to change the ``extra.symfony-web-dir`` option in the ``composer.json`` -file: +You also need to change the ``extra.symfony-web-dir`` option in the +``composer.json`` file: -.. code-block:: javascript +.. code-block:: json { - ... + "...": "...", "extra": { - ... + "...": "...", "symfony-web-dir": "my_new_web_dir" } } @@ -178,6 +182,7 @@ The change in the ``composer.json`` will look like this: Then, update the path to the ``autoload.php`` file in ``app/autoload.php``:: // app/autoload.php + // ... $loader = require '/some/dir/vendor/autoload.php'; From 47e11f85ede509177dd6c3d700ae4b42d6154cfe Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 13:37:13 +0100 Subject: [PATCH 26/41] Applied comments --- .../configuration_organization.rst | 21 ++++++------------- cookbook/deployment/azure-website.rst | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/cookbook/configuration/configuration_organization.rst b/cookbook/configuration/configuration_organization.rst index d6a5e4f1ade..d3a1fc85b2f 100644 --- a/cookbook/configuration/configuration_organization.rst +++ b/cookbook/configuration/configuration_organization.rst @@ -36,6 +36,7 @@ default Symfony Standard Edition follow this structure: your-project/ ├─ app/ + │ ├─ ... │ └─ config/ │ ├─ config.yml │ ├─ config_dev.yml @@ -46,11 +47,7 @@ default Symfony Standard Edition follow this structure: │ ├─ routing.yml │ ├─ routing_dev.yml │ └─ security.yml - ├─ src/ - ├─ tests/ - ├─ var/ - ├─ vendor/ - └─ web/ + ├─ ... This default structure was chosen for its simplicity — one file per environment. But as any other Symfony feature, you can customize it to better suit your needs. @@ -69,6 +66,7 @@ name as the environment: your-project/ ├─ app/ + │ ├─ ... │ └─ config/ │ ├─ common/ │ │ ├─ config.yml @@ -85,11 +83,7 @@ name as the environment: │ ├─ parameters.yml │ ├─ routing.yml │ └─ security.yml - ├─ src/ - ├─ tests/ - ├─ var/ - ├─ vendor/ - └─ web/ + ├─ ... To make this work, change the code of the :method:`Symfony\\Component\\HttpKernel\\KernelInterface::registerContainerConfiguration` @@ -167,6 +161,7 @@ and several files to define all application services: your-project/ ├─ app/ + │ ├─ ... │ └─ config/ │ ├─ bundles/ │ │ ├─ bundle1.yml @@ -186,11 +181,7 @@ and several files to define all application services: │ ├─ backend.yml │ ├─ ... │ └─ security.yml - ├─ src/ - ├─ tests/ - ├─ var/ - ├─ vendor/ - └─ web/ + ├─ ... Again, change the code of the ``registerContainerConfiguration()`` method to make Symfony aware of the new file organization:: diff --git a/cookbook/deployment/azure-website.rst b/cookbook/deployment/azure-website.rst index ba5e278b2d1..c13d8afc2ec 100644 --- a/cookbook/deployment/azure-website.rst +++ b/cookbook/deployment/azure-website.rst @@ -265,7 +265,7 @@ directory with at least the following contents: /var/logs/* !var/cache/.gitkeep !var/logs/.gitkeep - /bin/SymfonyRequirements.php + /var/SymfonyRequirements.php /build/ /vendor/ /bin/ From 25ae8c11b715d70c2e9d77ad68ddd5794e83491b Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 13:38:51 +0100 Subject: [PATCH 27/41] Applied suggestions --- book/page_creation.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/book/page_creation.rst b/book/page_creation.rst index c676a0f39ed..dc763c45a76 100644 --- a/book/page_creation.rst +++ b/book/page_creation.rst @@ -461,13 +461,13 @@ So what about the other directories in the project? file which is used to execute Symfony commands via the console. ``var/`` - This is were automatically created files are stored, like cache files + This is where automatically created files are stored, like cache files (``var/cache/``) and logs (``var/logs/``). ``vendor/`` - Vendor (i.e. third-party) libraries and bundles are downloaded here by - the `Composer`_ package manager. You should never need to manually edit - something in this directory. + Third-party libraries, packages and bundles are downloaded here by + the `Composer`_ package manager. You should never edit something in this + directory. .. seealso:: From 81c7572a415ba8ef58d7cc974b9e58a4af985eb1 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 28 Nov 2015 17:34:38 +0100 Subject: [PATCH 28/41] Removed scopes article --- book/service_container.rst | 1 - cookbook/map.rst.inc | 1 - cookbook/service_container/index.rst | 1 - cookbook/service_container/scopes.rst | 249 -------------------------- 4 files changed, 252 deletions(-) delete mode 100644 cookbook/service_container/scopes.rst diff --git a/book/service_container.rst b/book/service_container.rst index 2c777c8106e..a061b68945e 100644 --- a/book/service_container.rst +++ b/book/service_container.rst @@ -1182,7 +1182,6 @@ Learn more * :doc:`/components/dependency_injection/parentservices` * :doc:`/components/dependency_injection/tags` * :doc:`/cookbook/controller/service` -* :doc:`/cookbook/service_container/scopes` * :doc:`/cookbook/service_container/compiler_passes` * :doc:`/components/dependency_injection/advanced` diff --git a/cookbook/map.rst.inc b/cookbook/map.rst.inc index 98496abd7be..b175020f713 100644 --- a/cookbook/map.rst.inc +++ b/cookbook/map.rst.inc @@ -194,7 +194,6 @@ * :doc:`/cookbook/service_container/index` * :doc:`/cookbook/service_container/shared` - * :doc:`/cookbook/service_container/scopes` * :doc:`/cookbook/service_container/compiler_passes` * (Event Dispatcher) :doc:`/cookbook/event_dispatcher/event_listener` diff --git a/cookbook/service_container/index.rst b/cookbook/service_container/index.rst index f0166e75fd8..4c341ae4c1d 100644 --- a/cookbook/service_container/index.rst +++ b/cookbook/service_container/index.rst @@ -5,5 +5,4 @@ Service Container :maxdepth: 2 shared - scopes compiler_passes diff --git a/cookbook/service_container/scopes.rst b/cookbook/service_container/scopes.rst deleted file mode 100644 index 50e644b12f2..00000000000 --- a/cookbook/service_container/scopes.rst +++ /dev/null @@ -1,249 +0,0 @@ -.. index:: - single: DependencyInjection; Scopes - -How to Work with Scopes -======================= - -.. caution:: - - The "container scopes" concept explained in this article has been deprecated - in Symfony 2.8 and it will be removed in Symfony 3.0. - - Use the ``request_stack`` service (introduced in Symfony 2.4) instead of - the ``request`` service/scope and use the ``shared`` setting (introduced in - Symfony 2.8) instead of the ``prototype`` scope - (:doc:`read more about shared services `). - -This article is all about scopes, a somewhat advanced topic related to the -:doc:`/book/service_container`. If you've ever gotten an error mentioning -"scopes" when creating services, then this article is for you. - -.. note:: - - If you are trying to inject the ``request`` service, the simple solution - is to inject the ``request_stack`` service instead and access the current - Request by calling the - :method:`Symfony\\Component\\HttpFoundation\\RequestStack::getCurrentRequest` - method (see :ref:`book-container-request-stack`). The rest of this entry - talks about scopes in a theoretical and more advanced way. If you're - dealing with scopes for the ``request`` service, simply inject ``request_stack``. - -Understanding Scopes --------------------- - -The scope of a service controls how long an instance of a service is used -by the container. The DependencyInjection component provides two generic -scopes: - -``container`` (the default one): - The same instance is used each time you ask for it from this container. - -``prototype``: - A new instance is created each time you ask for the service. - -The -:class:`Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel` -also defines a third scope: ``request``. This scope is tied to the request, -meaning a new instance is created for each subrequest and is unavailable -outside the request (for instance in the CLI). - -An Example: Client Scope -~~~~~~~~~~~~~~~~~~~~~~~~ - -Other than the ``request`` service (which has a simple solution, see the -above note), no services in the default Symfony container belong to any -scope other than ``container`` and ``prototype``. But for the purposes of -this article, imagine there is another scope ``client`` and a service ``client_configuration`` -that belongs to it. This is not a common situation, but the idea is that -you may enter and exit multiple ``client`` scopes during a request, and each -has its own ``client_configuration`` service. - -Scopes add a constraint on the dependencies of a service: a service cannot -depend on services from a narrower scope. For example, if you create a generic -``my_foo`` service, but try to inject the ``client_configuration`` service, -you will receive a -:class:`Symfony\\Component\\DependencyInjection\\Exception\\ScopeWideningInjectionException` -when compiling the container. Read the sidebar below for more details. - -.. sidebar:: Scopes and Dependencies - - Imagine you've configured a ``my_mailer`` service. You haven't configured - the scope of the service, so it defaults to ``container``. In other words, - every time you ask the container for the ``my_mailer`` service, you get - the same object back. This is usually how you want your services to work. - - Imagine, however, that you need the ``client_configuration`` service - in your ``my_mailer`` service, maybe because you're reading some details - from it, such as what the "sender" address should be. You add it as a - constructor argument. There are several reasons why this presents a problem: - - * When requesting ``my_mailer``, an instance of ``my_mailer`` (called - *MailerA* here) is created and the ``client_configuration`` service ( - called *ConfigurationA* here) is passed to it. Life is good! - - * Your application now needs to do something with another client, and - you've designed your application in such a way that you handle this - by entering a new ``client_configuration`` scope and setting a new - ``client_configuration`` service into the container. Call this - *ConfigurationB*. - - * Somewhere in your application, you once again ask for the ``my_mailer`` - service. Since your service is in the ``container`` scope, the same - instance (*MailerA*) is just re-used. But here's the problem: the - *MailerA* instance still contains the old *ConfigurationA* object, which - is now **not** the correct configuration object to have (*ConfigurationB* - is now the current ``client_configuration`` service). This is subtle, - but the mis-match could cause major problems, which is why it's not - allowed. - - So, that's the reason *why* scopes exist, and how they can cause - problems. Keep reading to find out the common solutions. - -.. note:: - - A service can of course depend on a service from a wider scope without - any issue. - -Using a Service from a Narrower Scope -------------------------------------- - -There are two solutions to the scope problem: - -* A) Put your service in the same scope as the dependency (or a narrower one). If - you depend on the ``client_configuration`` service, this means putting your - new service in the ``client`` scope (see :ref:`changing-service-scope`); - -* B) Pass the entire container to your service and retrieve your dependency from - the container each time you need it to be sure you have the right instance - -- your service can live in the default ``container`` scope (see - :ref:`passing-container`). - -Each scenario is detailed in the following sections. - -.. _using-synchronized-service: - -.. note:: - - Prior to Symfony 2.7, there was another alternative based on ``synchronized`` - services. However, these kind of services have been deprecated starting from - Symfony 2.7. - -.. _changing-service-scope: - -A) Changing the Scope of your Service -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Changing the scope of a service should be done in its definition. This example -assumes that the ``Mailer`` class has a ``__construct`` function whose first -argument is the ``ClientConfiguration`` object: - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/services.yml - services: - my_mailer: - class: AppBundle\Mail\Mailer - scope: client - arguments: ["@client_configuration"] - - .. code-block:: xml - - - - - - - - - .. code-block:: php - - // app/config/services.php - use Symfony\Component\DependencyInjection\Definition; - - $definition = $container->setDefinition( - 'my_mailer', - new Definition( - 'AppBundle\Mail\Mailer', - array(new Reference('client_configuration'), - )) - )->setScope('client'); - -.. _passing-container: - -B) Passing the Container as a Dependency of your Service -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Setting the scope to a narrower one is not always possible (for instance, a -twig extension must be in the ``container`` scope as the Twig environment -needs it as a dependency). In these cases, you can pass the entire container -into your service:: - - // src/AppBundle/Mail/Mailer.php - namespace AppBundle\Mail; - - use Symfony\Component\DependencyInjection\ContainerInterface; - - class Mailer - { - protected $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - public function sendEmail() - { - $request = $this->container->get('client_configuration'); - // ... do something using the client configuration here - } - } - -.. caution:: - - Take care not to store the client configuration in a property of the object - for a future call of the service as it would cause the same issue described - in the first section (except that Symfony cannot detect that you are - wrong). - -The service configuration for this class would look something like this: - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/services.yml - services: - my_mailer: - class: AppBundle\Mail\Mailer - arguments: ["@service_container"] - # scope: container can be omitted as it is the default - - .. code-block:: xml - - - - - - - - - .. code-block:: php - - // app/config/services.php - use Symfony\Component\DependencyInjection\Definition; - use Symfony\Component\DependencyInjection\Reference; - - $container->setDefinition('my_mailer', new Definition( - 'AppBundle\Mail\Mailer', - array(new Reference('service_container')) - )); - -.. note:: - - Injecting the whole container into a service is generally not a good - idea (only inject what you need). From eff973345e16f768db23b515fb61d251b9595985 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 29 Nov 2015 23:29:11 -0500 Subject: [PATCH 29/41] removing more scope stuff --- book/service_container.rst | 14 -------------- components/dependency_injection/parentservices.rst | 3 +-- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/book/service_container.rst b/book/service_container.rst index a061b68945e..261c32b4183 100644 --- a/book/service_container.rst +++ b/book/service_container.rst @@ -884,20 +884,6 @@ Now, just inject the ``request_stack``, which behaves like any normal service: array(new Reference('request_stack')) )); -.. sidebar:: Why not Inject the ``request`` Service? - - Almost all Symfony2 built-in services behave in the same way: a single - instance is created by the container which it returns whenever you get it or - when it is injected into another service. There is one exception in a standard - Symfony2 application: the ``request`` service. - - If you try to inject the ``request`` into a service, you will probably receive - a - :class:`Symfony\\Component\\DependencyInjection\\Exception\\ScopeWideningInjectionException` - exception. That's because the ``request`` can **change** during the life-time - of a container (when a sub-request is created for instance). - - .. tip:: If you define a controller as a service then you can get the ``Request`` diff --git a/components/dependency_injection/parentservices.rst b/components/dependency_injection/parentservices.rst index 9237e57ac21..968686a0ea5 100644 --- a/components/dependency_injection/parentservices.rst +++ b/components/dependency_injection/parentservices.rst @@ -277,8 +277,7 @@ called when the child services are instantiated. .. caution:: - The ``scope``, ``abstract`` and ``tags`` attributes are always taken - from the child service. + The ``abstract`` and ``tags`` attributes are always taken from the child service. The parent service is abstract as it should not be directly retrieved from the container or passed into another service. It exists merely as a "template" From 1a2753901edfe8a101846323577c160e3459540d Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 29 Nov 2015 23:32:31 -0500 Subject: [PATCH 30/41] removing scope reference --- create_framework/dependency-injection.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_framework/dependency-injection.rst b/create_framework/dependency-injection.rst index 39eaae4702e..725a8c019e1 100644 --- a/create_framework/dependency-injection.rst +++ b/create_framework/dependency-injection.rst @@ -219,7 +219,7 @@ And the related change in the front controller:: We have obviously barely scratched the surface of what you can do with the container: from class names as parameters, to overriding existing object -definitions, from scope support to dumping a container to a plain PHP class, +definitions, from shared service support to dumping a container to a plain PHP class, and much more. The Symfony dependency injection container is really powerful and is able to manage any kind of PHP class. From 0e53bb580d418f7cdfef5336daaa18a6a52f3398 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 29 Nov 2015 23:50:01 -0500 Subject: [PATCH 31/41] [#5917] Adding bin --- cookbook/configuration/override_dir_structure.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cookbook/configuration/override_dir_structure.rst b/cookbook/configuration/override_dir_structure.rst index 5982d2bf80e..e389b3ef837 100644 --- a/cookbook/configuration/override_dir_structure.rst +++ b/cookbook/configuration/override_dir_structure.rst @@ -14,6 +14,8 @@ directory structure is: ├─ app/ │ ├─ config/ │ └─ ... + ├─ bin/ + │ └─ ... ├─ src/ │ └─ ... ├─ tests/ From 3083e90a560af5dd3134b568a4d8a5de9babd183 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Mon, 30 Nov 2015 00:00:12 -0500 Subject: [PATCH 32/41] [#5917] Finding some more places with the old directory structure referenced --- book/testing.rst | 41 ++++++++----------- .../configuration/override_dir_structure.rst | 2 +- cookbook/deployment/azure-website.rst | 2 +- cookbook/deployment/platformsh.rst | 2 +- cookbook/testing/bootstrap.rst | 4 +- quick_tour/the_architecture.rst | 2 +- 6 files changed, 24 insertions(+), 29 deletions(-) diff --git a/book/testing.rst b/book/testing.rst index 59d2c2c5428..4d0a9d3613b 100644 --- a/book/testing.rst +++ b/book/testing.rst @@ -21,13 +21,12 @@ it has its own excellent `documentation`_. to use version 4.2 or higher to test the Symfony core code itself). Each test - whether it's a unit test or a functional test - is a PHP class -that should live in the ``Tests/`` subdirectory of your bundles. If you follow +that should live in the ``tests/`` directory of your application. If you follow this rule, then you can run all of your application's tests with the following command: .. code-block:: bash - # specify the configuration directory on the command line $ phpunit PHPunit is configured by the ``phpunit.xml.dist`` file in the root of your @@ -63,11 +62,11 @@ called ``Calculator`` in the ``Util/`` directory of the app bundle:: } } -To test this, create a ``CalculatorTest`` file in the ``Tests/Util`` directory +To test this, create a ``CalculatorTest`` file in the ``tests/AppBundle/Util`` directory of your bundle:: - // src/AppBundle/Tests/Util/CalculatorTest.php - namespace AppBundle\Tests\Util; + // tests/AppBundle/Util/CalculatorTest.php + namespace Tests\AppBundle\Util; use AppBundle\Util\Calculator; @@ -85,13 +84,13 @@ of your bundle:: .. note:: - By convention, the ``Tests/`` sub-directory should replicate the directory - of your bundle for unit tests. So, if you're testing a class in your - bundle's ``Util/`` directory, put the test in the ``Tests/Util/`` + By convention, the ``Tests/AppBundle`` directory should replicate the directory + of your bundle for unit tests. So, if you're testing a class in the + ``AppBundle/Util/`` directory, put the test in the ``tests/AppBundle/Util/`` directory. Just like in your real application - autoloading is automatically enabled -via the ``bootstrap.php.cache`` file (as configured by default in the +via the ``autoload.php`` file (as configured by default in the ``phpunit.xml.dist`` file). Running tests for a given file or directory is also very easy: @@ -102,13 +101,13 @@ Running tests for a given file or directory is also very easy: $ phpunit # run all tests in the Util directory - $ phpunit src/AppBundle/Tests/Util + $ phpunit tests/AppBundle/Util # run tests for the Calculator class - $ phpunit src/AppBundle/Tests/Util/CalculatorTest.php + $ phpunit tests/AppBundle/Util/CalculatorTest.php # run all tests for the entire Bundle - $ phpunit src/AppBundle/ + $ phpunit tests/AppBundle/ .. index:: single: Tests; Functional tests @@ -129,15 +128,15 @@ tests as far as PHPUnit is concerned, but they have a very specific workflow: Your First Functional Test ~~~~~~~~~~~~~~~~~~~~~~~~~~ -Functional tests are simple PHP files that typically live in the ``Tests/Controller`` -directory of your bundle. If you want to test the pages handled by your +Functional tests are simple PHP files that typically live in the ``tests/AppBundle/Controller`` +directory for your bundle. If you want to test the pages handled by your ``PostController`` class, start by creating a new ``PostControllerTest.php`` file that extends a special ``WebTestCase`` class. As an example, a test could look like this:: - // src/AppBundle/Tests/Controller/PostControllerTest.php - namespace AppBundle\Tests\Controller; + // tests/AppBundle/Controller/PostControllerTest.php + namespace Tests\AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -810,10 +809,8 @@ only. Store the ``phpunit.xml.dist`` file in your code repository and ignore the ``phpunit.xml`` file. -By default, only the tests from your own custom bundles stored in the standard -directories ``src/*/*Bundle/Tests``, ``src/*/Bundle/*Bundle/Tests``, -``src/*Bundle/Tests`` are run by the ``phpunit`` command, as configured -in the ``phpunit.xml.dist`` file: +By default, only the tests stored in ``/tests`` are run via the ``phpunit`` command, +as configured in the ``phpunit.xml.dist`` file: .. code-block:: xml @@ -822,9 +819,7 @@ in the ``phpunit.xml.dist`` file: - ../src/*/*Bundle/Tests - ../src/*/Bundle/*Bundle/Tests - ../src/*Bundle/Tests + tests diff --git a/cookbook/configuration/override_dir_structure.rst b/cookbook/configuration/override_dir_structure.rst index e389b3ef837..7ee57bb0ce1 100644 --- a/cookbook/configuration/override_dir_structure.rst +++ b/cookbook/configuration/override_dir_structure.rst @@ -97,7 +97,7 @@ in your ``app.php`` and ``app_dev.php`` front controllers. If you simply renamed the directory, you're fine. But if you moved it in some way, you may need to modify these paths inside those files:: - require_once __DIR__.'/../path/to/var/bootstrap.php.cache'; + require_once __DIR__.'/../path/to/app/autoload.php'; You also need to change the ``extra.symfony-web-dir`` option in the ``composer.json`` file: diff --git a/cookbook/deployment/azure-website.rst b/cookbook/deployment/azure-website.rst index c13d8afc2ec..0480442fabd 100644 --- a/cookbook/deployment/azure-website.rst +++ b/cookbook/deployment/azure-website.rst @@ -259,7 +259,7 @@ directory with at least the following contents: .. code-block:: text - /app/bootstrap.php.cache + /var/bootstrap.php.cache /var/cache/* /app/config/parameters.yml /var/logs/* diff --git a/cookbook/deployment/platformsh.rst b/cookbook/deployment/platformsh.rst index 9ca118f197e..8bed82d548e 100644 --- a/cookbook/deployment/platformsh.rst +++ b/cookbook/deployment/platformsh.rst @@ -63,7 +63,7 @@ Platform.sh how to deploy your application (read more about # The mounts that will be performed when the package is deployed. mounts: "/var/cache": "shared:files/cache" - "/app/logs": "shared:files/logs" + "/var/logs": "shared:files/logs" # The hooks that will be performed when the package is deployed. hooks: diff --git a/cookbook/testing/bootstrap.rst b/cookbook/testing/bootstrap.rst index 1f3c5464e41..67ad9db1d8e 100644 --- a/cookbook/testing/bootstrap.rst +++ b/cookbook/testing/bootstrap.rst @@ -17,9 +17,9 @@ First, add the following file:: )); } - require __DIR__.'/bootstrap.php.cache'; + require __DIR__.'/autoload.php'; -Replace the test bootstrap file ``bootstrap.php.cache`` in ``phpunit.xml.dist`` +Replace the test bootstrap file ``autoload.php`` in ``phpunit.xml.dist`` with ``tests.bootstrap.php``: .. code-block:: xml diff --git a/quick_tour/the_architecture.rst b/quick_tour/the_architecture.rst index a345807af66..1a973516815 100644 --- a/quick_tour/the_architecture.rst +++ b/quick_tour/the_architecture.rst @@ -286,7 +286,7 @@ and help you fix the problem quickly. Using the Command Line Interface -------------------------------- -Each application comes with a command line interface tool (``app/console``) +Each application comes with a command line interface tool (``bin/console``) that helps you maintain your application. It provides commands that boost your productivity by automating tedious and repetitive tasks. From d5778488d4fbd1a62fd56860202d5e1f3cf84db3 Mon Sep 17 00:00:00 2001 From: ogizanagi Date: Thu, 3 Dec 2015 17:31:28 +0100 Subject: [PATCH 33/41] Update docs accordingly to min PHP version requirement --- book/forms.rst | 4 +--- book/security.rst | 2 -- components/dom_crawler.rst | 6 ------ components/form/introduction.rst | 7 +------ components/var_dumper/introduction.rst | 5 ----- contributing/code/patches.rst | 8 ++++---- cookbook/configuration/micro-kernel-trait.rst | 6 ------ cookbook/deployment/azure-website.rst | 4 ++-- .../security/_ircmaxwell_password-compat.rst.inc | 13 ------------- cookbook/security/entity_provider.rst | 2 -- create_framework/introduction.rst | 7 +++---- reference/configuration/security.rst | 5 ----- reference/requirements.rst | 7 +------ 13 files changed, 12 insertions(+), 64 deletions(-) delete mode 100644 cookbook/security/_ircmaxwell_password-compat.rst.inc diff --git a/book/forms.rst b/book/forms.rst index cab2b60a11b..384cc9cbd8e 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -95,8 +95,6 @@ from inside a controller:: $form = $this->createFormBuilder($task) ->add('task', TextType::class) - // If you use PHP 5.3 or 5.4 you must use - // ->add('task', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->add('dueDate', DateType::class) ->add('save', SubmitType::class, array('label' => 'Create Task')) ->getForm(); @@ -1978,4 +1976,4 @@ Learn more from the Cookbook .. _`form_div_layout.html.twig`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig .. _`Cross-site request forgery`: http://en.wikipedia.org/wiki/Cross-site_request_forgery .. _`view on GitHub`: https://github.com/symfony/symfony/tree/master/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form -.. _`2.8 UPGRADE Log`: https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#form \ No newline at end of file +.. _`2.8 UPGRADE Log`: https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#form diff --git a/book/security.rst b/book/security.rst index 5f410cac2ac..e0d5c3cb2a0 100644 --- a/book/security.rst +++ b/book/security.rst @@ -510,8 +510,6 @@ else, you'll want to encode their passwords. The best algorithm to use is // ... )); -.. include:: /cookbook/security/_ircmaxwell_password-compat.rst.inc - Of course, your users' passwords now need to be encoded with this exact algorithm. For hardcoded users, you can use an `online tool`_, which will give you something like this: diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 2bb74fb4ac4..f9a3fe030f3 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -300,12 +300,6 @@ and :phpclass:`DOMNode` objects: The ``html`` method is new in Symfony 2.3. - .. caution:: - - Due to an issue in PHP, the ``html()`` method returns wrongly decoded HTML - entities in PHP versions lower than 5.3.6 (for example, it returns ``•`` - instead of ``•``). - Links ~~~~~ diff --git a/components/form/introduction.rst b/components/form/introduction.rst index 36a13fb9d28..a6515aa3aac 100644 --- a/components/form/introduction.rst +++ b/components/form/introduction.rst @@ -398,8 +398,6 @@ is created from the form factory. $form = $formFactory->createBuilder() ->add('task', TextType::class) - // If you use PHP 5.3 or 5.4, you must use - // ->add('task', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->add('dueDate', DateType::class) ->getForm(); @@ -426,8 +424,6 @@ is created from the form factory. $form = $this->createFormBuilder() ->add('task', TextType::class) - // If you use PHP 5.3 or 5.4, you must use - // ->add('task', 'Symfony\Component\Form\Extension\Core\Type\TextType') ->add('dueDate', DateType::class) ->getForm(); @@ -439,8 +435,7 @@ is created from the form factory. As you can see, creating a form is like writing a recipe: you call ``add`` for each new field you want to create. The first argument to ``add`` is the -name of your field, and the second is the fully qualified class name. If you -use PHP 5.5 or above, you can use ``::class`` constant of a form type. The Form +name of your field, and the second is the fully qualified class name. The Form component comes with a lot of :doc:`built-in types `. Now that you've built your form, learn how to :ref:`render ` diff --git a/components/var_dumper/introduction.rst b/components/var_dumper/introduction.rst index 8f11a198c4d..9e97e3ec15d 100644 --- a/components/var_dumper/introduction.rst +++ b/components/var_dumper/introduction.rst @@ -145,11 +145,6 @@ Example:: } } -.. tip:: - - If you still use PHP 5.3, you can extend the - :class:`Symfony\\Component\\VarDumper\\Test\\VarDumperTestClass` instead. - Dump Examples and Output ------------------------ diff --git a/contributing/code/patches.rst b/contributing/code/patches.rst index 7d5ef0c3452..b4f0b2ba4fa 100644 --- a/contributing/code/patches.rst +++ b/contributing/code/patches.rst @@ -14,14 +14,14 @@ Before working on Symfony, setup a friendly environment with the following software: * Git; -* PHP version 5.3.9 or above; +* PHP version 5.5.9 or above; * `PHPUnit`_ 4.2 or above. .. caution:: - Before Symfony 2.7, the minimal PHP version was 5.3.3. Please keep - this in mind, if you are working on a bug fix for earlier versions - of Symfony. + Before Symfony 2.7, the minimal PHP version was 5.3.3. Before Symfony 3.0, + minimal version was 5.3.9. Please keep this in mind, if you are working on a + bug fix for earlier versions of Symfony. Configure Git ~~~~~~~~~~~~~ diff --git a/cookbook/configuration/micro-kernel-trait.rst b/cookbook/configuration/micro-kernel-trait.rst index 79f1d474f6d..7e4563f34bb 100644 --- a/cookbook/configuration/micro-kernel-trait.rst +++ b/cookbook/configuration/micro-kernel-trait.rst @@ -11,12 +11,6 @@ as one file? This is possible thanks to the new you to start with a tiny application, and then add features and structure as you need to. -.. note:: - - The MicroKernelTrait requires PHP 5.4. However, there's nothing special about - this trait. If you're using PHP 5.3, simply copy its methods into *your* kernel - class to get the same functionality. - A Single-File Symfony Application --------------------------------- diff --git a/cookbook/deployment/azure-website.rst b/cookbook/deployment/azure-website.rst index 0480442fabd..54c6175b55f 100644 --- a/cookbook/deployment/azure-website.rst +++ b/cookbook/deployment/azure-website.rst @@ -96,8 +96,8 @@ and how to properly configure PHP for a production environment. Configuring the latest PHP Runtime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Even though Symfony only requires PHP 5.3.9 to run, it's always recommended -to use the most recent PHP version whenever possible. PHP 5.3 is no longer +Even though Symfony only requires PHP 5.5.9 to run, it's always recommended +to use the most recent PHP version whenever possible. Earlier versions are no longer supported by the PHP core team, but you can update it easily in Azure. To update your PHP version on Azure, go to the **Configure** tab of the control diff --git a/cookbook/security/_ircmaxwell_password-compat.rst.inc b/cookbook/security/_ircmaxwell_password-compat.rst.inc deleted file mode 100644 index 3f96c454488..00000000000 --- a/cookbook/security/_ircmaxwell_password-compat.rst.inc +++ /dev/null @@ -1,13 +0,0 @@ -.. caution:: - - If you're using PHP 5.4 or lower, you'll need to install the ``ircmaxell/password-compat`` - library via Composer in order to be able to use the ``bcrypt`` encoder: - - .. code-block:: json - - { - "require": { - ... - "ircmaxell/password-compat": "~1.0.3" - } - } diff --git a/cookbook/security/entity_provider.rst b/cookbook/security/entity_provider.rst index ced1039a28a..5b435ecf799 100644 --- a/cookbook/security/entity_provider.rst +++ b/cookbook/security/entity_provider.rst @@ -291,8 +291,6 @@ name ``our_db_provider`` isn't important: it just needs to match the value of the ``provider`` key under your firewall. Or, if you don't set the ``provider`` key under your firewall, the first "user provider" is automatically used. -.. include:: /cookbook/security/_ircmaxwell_password-compat.rst.inc - Creating your First User ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/create_framework/introduction.rst b/create_framework/introduction.rst index 1d1bb864639..ead809f4ca8 100644 --- a/create_framework/introduction.rst +++ b/create_framework/introduction.rst @@ -69,7 +69,7 @@ Before You Start Reading about how to create a framework is not enough. You will have to follow along and actually type all the examples included in this tutorial. For that, -you need a recent version of PHP (5.3.9 or later is good enough), a web server +you need a recent version of PHP (5.5.9 or later is good enough), a web server (like Apache, NGinx or PHP's built-in web server), a good knowledge of PHP and an understanding of Object Oriented programming. @@ -109,9 +109,8 @@ start with the simplest web application we can think of in PHP:: printf('Hello %s', $input); -If you have PHP 5.4, you can use the PHP built-in server to test this great -application in a browser (``http://localhost:4321/index.php?name=Fabien``). -Otherwise, use your own server (Apache, Nginx, etc.): +You can use the PHP built-in server to test this great +application in a browser (``http://localhost:4321/index.php?name=Fabien``): .. code-block:: bash diff --git a/reference/configuration/security.rst b/reference/configuration/security.rst index 7ebc489b2eb..22c99a171e2 100644 --- a/reference/configuration/security.rst +++ b/reference/configuration/security.rst @@ -354,11 +354,6 @@ for the hash algorithm. Using the BCrypt Password Encoder --------------------------------- -.. caution:: - - To use this encoder, you either need to use PHP Version 5.5 or install - the `ircmaxell/password-compat`_ library via Composer. - .. configuration-block:: .. code-block:: yaml diff --git a/reference/requirements.rst b/reference/requirements.rst index a0f9e262846..9ff4d99665d 100644 --- a/reference/requirements.rst +++ b/reference/requirements.rst @@ -21,16 +21,11 @@ Below is the list of required and optional requirements. Required -------- -* PHP needs to be a minimum version of PHP 5.3.9 +* PHP needs to be a minimum version of PHP 5.5.9 * JSON needs to be enabled * ctype needs to be enabled * Your ``php.ini`` needs to have the ``date.timezone`` setting -.. caution:: - - Be aware that Symfony has some known limitations when using PHP 5.3.16. - For more information see the `Requirements section of the README`_. - Optional -------- From 8c170337051dee49f51320260040f19bd9ddb013 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 5 Dec 2015 10:54:02 +0100 Subject: [PATCH 34/41] [#5948] Very minor detail --- create_framework/introduction.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create_framework/introduction.rst b/create_framework/introduction.rst index ead809f4ca8..31c03ed3c6d 100644 --- a/create_framework/introduction.rst +++ b/create_framework/introduction.rst @@ -109,8 +109,8 @@ start with the simplest web application we can think of in PHP:: printf('Hello %s', $input); -You can use the PHP built-in server to test this great -application in a browser (``http://localhost:4321/index.php?name=Fabien``): +You can use the PHP built-in server to test this great application in a browser +(``http://localhost:4321/index.php?name=Fabien``): .. code-block:: bash From 7d922b9058f1364cb36e3e736f5f1418ad7397a4 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 9 Dec 2015 09:19:18 +0100 Subject: [PATCH 35/41] [#5956] change app/console back to bin/console --- book/security.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/security.rst b/book/security.rst index 435b563df3e..668830e468b 100644 --- a/book/security.rst +++ b/book/security.rst @@ -515,7 +515,7 @@ For hardcoded users, since 2.7 you can use the built-in command : .. code-block:: bash - $ php app/console security:encode-password + $ php bin/console security:encode-password It will give you something like this: From e19f7a10b64866d0cb10ff8eac2cb0977bdbe9f1 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 9 Dec 2015 20:39:14 +0100 Subject: [PATCH 36/41] [#5957] remove deep parameter documentation --- reference/constraints/Valid.rst | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index 67ec4bc86a6..e52e9e53bf1 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -9,7 +9,6 @@ an object and all sub-objects associated with it. | Applies to | :ref:`property or method ` | +----------------+---------------------------------------------------------------------+ | Options | - `traverse`_ | -| | - `deep`_ (deprecated as of 2.5) | | | - `payload`_ | +----------------+---------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Validator\\Constraints\\Valid` | @@ -268,19 +267,4 @@ If this constraint is applied to a property that holds an array of objects, then each object in that array will be validated only if this option is set to ``true``. -deep -~~~~ - -.. caution:: - - The ``deep`` option was deprecated in Symfony 2.5 and will be removed - in Symfony 3.0. When traversing arrays, nested arrays are always traversed. - When traversing nested objects, their traversal strategy is used. - -**type**: ``boolean`` **default**: ``false`` - -If this constraint is applied to a property that holds an array of objects, -then each object in that array will be validated recursively if this option -is set to ``true``. - .. include:: /reference/constraints/_payload-option.rst.inc From 276aa1f4c6ec45449c8c71d8d186b06c3d2de2a9 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 12 Dec 2015 11:41:27 +0100 Subject: [PATCH 37/41] Added october and november changelog --- changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.rst b/changelog.rst index 469cb626087..88182ddac88 100644 --- a/changelog.rst +++ b/changelog.rst @@ -19,6 +19,9 @@ November, 2015 New Documentation ~~~~~~~~~~~~~~~~~ +* `#5917 `_ [3.0][Cookbook] Use the 3.0 directory structure (WouterJ) +* `#5916 `_ [3.0][Best Practices][Quick Tour] Use the 3.0 directory structure (WouterJ) +* `#5913 `_ [3.0][Book] Use the 3.0 directory structure (WouterJ) * `#5907 `_ Updating some places to use the new CustomUserMessageAuthenticationException (weaverryan) * `#5922 `_ Added minimal cookbook article about the shared flag (WouterJ) * `#5908 `_ Voter update (weaverryan) From a7effb888b8c1abb0bc789be01a10a2f327b6ee4 Mon Sep 17 00:00:00 2001 From: Zac Sturgess Date: Thu, 17 Dec 2015 16:36:44 +0000 Subject: [PATCH 38/41] Fix #6037 --- components/yaml/introduction.rst | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/components/yaml/introduction.rst b/components/yaml/introduction.rst index adb0d0956e6..c4104e01e40 100644 --- a/components/yaml/introduction.rst +++ b/components/yaml/introduction.rst @@ -135,16 +135,9 @@ It may also be convenient to use the $yaml = Yaml::parse(file_get_contents('/path/to/file.yml')); -The :method:`Symfony\\Component\\Yaml\\Yaml::parse` static method takes a YAML -string or a file containing YAML. Internally, it calls the -:method:`Symfony\\Component\\Yaml\\Parser::parse` method, but enhances the -error if something goes wrong by adding the filename to the message. - -.. caution:: - - Because it is currently possible to pass a filename to this method, you - must validate the input first. Passing a filename is deprecated in - Symfony 2.2, and will be removed in Symfony 3.0. +The :method:`Symfony\\Component\\Yaml\\Yaml::parse` static method takes a YAML string. +Internally, it constructs a :class:`Symfony\\Component\\Yaml\\Parser` object and calls +the :method:`Symfony\\Component\\Yaml\\Parser::parse` method. .. _components-yaml-dump: From 786096e8ce6cd97419a631ac2a47b8141c0b6673 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Fri, 18 Dec 2015 11:33:58 +0100 Subject: [PATCH 39/41] Update Symfony version to 3.0 --- book/installation.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/book/installation.rst b/book/installation.rst index db176b350a9..54ce48ec930 100644 --- a/book/installation.rst +++ b/book/installation.rst @@ -97,15 +97,15 @@ optional second argument of the ``new`` command: .. code-block:: bash # use the most recent version in any Symfony branch - $ symfony new my_project_name 2.6 $ symfony new my_project_name 2.8 + $ symfony new my_project_name 3.0 # use a specific Symfony version $ symfony new my_project_name 2.7.3 $ symfony new my_project_name 2.8.1 # use a beta or RC version (useful for testing new Symfony versions) - $ symfony new my_project 2.8.0-BETA1 + $ symfony new my_project 3.0.0-BETA1 $ symfony new my_project 2.7.0-RC1 The installer also supports a special version called ``lts`` which installs the @@ -152,7 +152,7 @@ version as the second argument of the ``create-project`` command: .. code-block:: bash - $ composer create-project symfony/framework-standard-edition my_project_name "2.8.*" + $ composer create-project symfony/framework-standard-edition my_project_name "3.0.*" .. tip:: From 3b2939f79405642edd0679343c8b260f8b74fe27 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Fri, 18 Dec 2015 11:34:34 +0100 Subject: [PATCH 40/41] Update Symfony version to 3.1 --- book/installation.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/book/installation.rst b/book/installation.rst index 54ce48ec930..5e6a97b75a1 100644 --- a/book/installation.rst +++ b/book/installation.rst @@ -98,15 +98,15 @@ optional second argument of the ``new`` command: # use the most recent version in any Symfony branch $ symfony new my_project_name 2.8 - $ symfony new my_project_name 3.0 + $ symfony new my_project_name 3.1 # use a specific Symfony version - $ symfony new my_project_name 2.7.3 $ symfony new my_project_name 2.8.1 + $ symfony new my_project_name 3.0.2 # use a beta or RC version (useful for testing new Symfony versions) $ symfony new my_project 3.0.0-BETA1 - $ symfony new my_project 2.7.0-RC1 + $ symfony new my_project 3.1.0-RC1 The installer also supports a special version called ``lts`` which installs the most recent :ref:`Symfony LTS version ` available: @@ -152,7 +152,7 @@ version as the second argument of the ``create-project`` command: .. code-block:: bash - $ composer create-project symfony/framework-standard-edition my_project_name "3.0.*" + $ composer create-project symfony/framework-standard-edition my_project_name "3.1.*" .. tip:: From d5a2c069a1ce500960a3e2640e594363cfa68fc6 Mon Sep 17 00:00:00 2001 From: Tristan Roussel Date: Sat, 5 Dec 2015 02:33:58 +0100 Subject: [PATCH 41/41] Document constraint validator alias optional --- cookbook/validation/custom_constraint.rst | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/cookbook/validation/custom_constraint.rst b/cookbook/validation/custom_constraint.rst index a248a8494aa..1adf5edf1eb 100644 --- a/cookbook/validation/custom_constraint.rst +++ b/cookbook/validation/custom_constraint.rst @@ -167,7 +167,7 @@ Constraint Validators with Dependencies If your constraint validator has dependencies, such as a database connection, it will need to be configured as a service in the Dependency Injection Container. This service must include the ``validator.constraint_validator`` -tag and an ``alias`` attribute: +tag and may include an ``alias`` attribute: .. configuration-block:: @@ -195,21 +195,14 @@ tag and an ``alias`` attribute: ->register('validator.unique.your_validator_name', 'Fully\Qualified\Validator\Class\Name') ->addTag('validator.constraint_validator', array('alias' => 'alias_name')); -Your constraint class should now use this alias to reference the appropriate -validator:: +As mentioned above, Symfony will automatically look for a class named after +the constraint, with ``Validator`` appended. You can override this in you constraint class:: public function validatedBy() { - return 'alias_name'; + return 'Fully\Qualified\Class\Named\ConstraintValidator'; \\ or 'alias_name' if provided } -As mentioned above, Symfony will automatically look for a class named after -the constraint, with ``Validator`` appended. If your constraint validator -is defined as a service, it's important that you override the -``validatedBy()`` method to return the alias used when defining your service, -otherwise Symfony won't use the constraint validator service, and will -instantiate the class instead, without any dependencies injected. - Class Constraint Validator ~~~~~~~~~~~~~~~~~~~~~~~~~~