diff --git a/best_practices/business-logic.rst b/best_practices/business-logic.rst
index 6817cbf3562..21f066dbe49 100644
--- a/best_practices/business-logic.rst
+++ b/best_practices/business-logic.rst
@@ -15,7 +15,7 @@ Inside here, you can create whatever directories you want to organize things:
.. code-block:: text
- symfony2-project/
+ symfony-project/
├─ app/
├─ src/
│ └─ AppBundle/
@@ -35,7 +35,7 @@ and put things there:
.. code-block:: text
- symfony2-project/
+ symfony-project/
├─ app/
├─ src/
│ ├─ Acme/
@@ -180,7 +180,7 @@ The three entities defined by our sample blog application are a good example:
.. code-block:: text
- symfony2-project/
+ symfony-project/
├─ ...
└─ src/
└─ AppBundle/
diff --git a/best_practices/controllers.rst b/best_practices/controllers.rst
index b30b27a15de..98e55f4eef7 100644
--- a/best_practices/controllers.rst
+++ b/best_practices/controllers.rst
@@ -85,10 +85,10 @@ it more difficult to know which template is being rendered. It also makes
it less obvious to beginners that a controller should always return a Response
object (unless you're using a view layer).
-How the Controller Looks
-------------------------
+What does the Controller look like
+----------------------------------
-Considering all this, here is an example of how the controller should look
+Considering all this, here is an example of what the controller should look like
for the homepage of our app:
.. code-block:: php
diff --git a/components/cache/cache_pools.rst b/components/cache/cache_pools.rst
index 3b064822bcd..ed1311ce416 100644
--- a/components/cache/cache_pools.rst
+++ b/components/cache/cache_pools.rst
@@ -169,7 +169,7 @@ is ``getItem($key)``, which returns the cache item identified by the given key::
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
- $cache = new FilesystemAdapter('app.cache')
+ $cache = new FilesystemAdapter('app.cache');
$latestNews = $cache->getItem('latest_news');
If no item is defined for the given key, the method doesn't return a ``null``
diff --git a/components/expression_language.rst b/components/expression_language.rst
index bb0cf1c510d..ad7f3f924f6 100644
--- a/components/expression_language.rst
+++ b/components/expression_language.rst
@@ -21,7 +21,7 @@ How can the Expression Engine Help Me?
--------------------------------------
The purpose of the component is to allow users to use expressions inside
-configuration for more complex logic. For some examples, the Symfony2 Framework
+configuration for more complex logic. For some examples, the Symfony Framework
uses expressions in security, for validation rules and in route matching.
Besides using the component in the framework itself, the ExpressionLanguage
diff --git a/components/filesystem.rst b/components/filesystem.rst
index c787295e257..6386fad4bbb 100644
--- a/components/filesystem.rst
+++ b/components/filesystem.rst
@@ -60,6 +60,10 @@ On POSIX filesystems, directories are created with a default mode value
You can pass an array or any :phpclass:`Traversable` object as the first
argument.
+.. note::
+
+ This function ignores already existing directories.
+
exists
~~~~~~
diff --git a/components/yaml/yaml_format.rst b/components/yaml/yaml_format.rst
index 2e9d24a95ef..1f7ef6d98a3 100644
--- a/components/yaml/yaml_format.rst
+++ b/components/yaml/yaml_format.rst
@@ -158,7 +158,7 @@ YAML uses the ISO-8601 standard to express dates:
.. code-block:: yaml
- 2001-12-14t21:59:43.10-05:00
+ 2001-12-14T21:59:43.10-05:00
.. code-block:: yaml
diff --git a/configuration.rst b/configuration.rst
index 89ffa16d5eb..dc039ce6ce1 100644
--- a/configuration.rst
+++ b/configuration.rst
@@ -112,14 +112,14 @@ There are *two* ways to know *what* keys you can configure:
#. Use the :doc:`Reference Section `;
-#. Use the ``config:dump`` command;
+#. Use the ``config:dump-reference`` command.
For example, if you want to configure something in Twig, you can see an example
dump of all available configuration options by running:
.. code-block:: terminal
- $ php bin/console config:dump twig
+ $ php bin/console config:dump-reference twig
.. index::
single: Environments; Introduction
@@ -183,7 +183,7 @@ can also load XML files or PHP files.
.. _config-parameter-intro:
-The parameters key: Parameters (Variables)
+The parameters Key: Parameters (Variables)
------------------------------------------
Another special key is called ``parameters``: it's used to define *variables* that
diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst
index 7c8efb40945..383360a2012 100644
--- a/configuration/micro_kernel_trait.rst
+++ b/configuration/micro_kernel_trait.rst
@@ -199,13 +199,13 @@ to hold the kernel. Now it looks like this::
// optional, to use the standard Symfony cache directory
public function getCacheDir()
{
- return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
+ return __DIR__.'/../var/cache/'.$this->getEnvironment();
}
// optional, to use the standard Symfony logs directory
public function getLogDir()
{
- return dirname(__DIR__).'/var/logs';
+ return __DIR__.'/../var/logs';
}
}
diff --git a/controller.rst b/controller.rst
index e3d77fd9333..4130b489dde 100644
--- a/controller.rst
+++ b/controller.rst
@@ -320,7 +320,7 @@ object. To get it in your controller, just add it as an argument and
use Symfony\Component\HttpFoundation\Request;
- public function indexAction($firstName, $lastName, Request $request)
+ public function indexAction(Request $request, $firstName, $lastName)
{
$page = $request->query->get('page', 1);
diff --git a/form/form_dependencies.rst b/form/form_dependencies.rst
index 5e727039797..7eb710850b4 100644
--- a/form/form_dependencies.rst
+++ b/form/form_dependencies.rst
@@ -101,6 +101,7 @@ Next, register this as a service and tag it with ``form.type``:
services:
app.form.type.task:
class: AppBundle\Form\TaskType
+ arguments: ['@doctrine.orm.entity_manager']
tags:
- { name: form.type }
@@ -114,6 +115,7 @@ Next, register this as a service and tag it with ``form.type``:
+
@@ -127,6 +129,7 @@ Next, register this as a service and tag it with ``form.type``:
'app.form.type.task',
'AppBundle\Form\TaskType'
)
+ ->addArgument('@doctrine.orm.entity_manager')
->addTag('form.type')
;
diff --git a/page_creation.rst b/page_creation.rst
index 133f71a5c42..cf4409f08e9 100644
--- a/page_creation.rst
+++ b/page_creation.rst
@@ -86,7 +86,7 @@ to creating a page?
#. *Create a controller*: The method below the route - ``numberAction()`` - is called
the *controller*: this is a function where *you* build the page and ultimately
return a ``Response`` object. You'll learn more about :doc:`controllers `
- in their own section, including how to return JSON responses;
+ in their own section, including how to return JSON responses.
The Web Debug Toolbar: Debugging Dream
--------------------------------------
@@ -134,7 +134,7 @@ variable so we can render that::
$number = mt_rand(0, 100);
return $this->render('lucky/number.html.twig', array(
- 'number' => $number
+ 'number' => $number,
));
}
}
@@ -184,7 +184,7 @@ So what about the other directories in the project?
``var/``
This is where automatically-created files are stored, like cache files
- (``var/cache/``) and logs (``var/logs/``).
+ (``var/cache/``), logs (``var/logs/``) and sessions (``var/sessions/``).
``vendor/``
Third-party (i.e. "vendor") libraries live here! These are downloaded via the `Composer`_
diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst
index 9b7af25f43e..117ba48bf4c 100644
--- a/reference/configuration/framework.rst
+++ b/reference/configuration/framework.rst
@@ -100,7 +100,7 @@ Configuration
* :ref:`enabled `
* :ref:`cache `
* :ref:`enable_annotations `
- * `name_converter`_
+ * :ref:`name_converter `
* `php_errors`_
* `log`_
* `throw`_
@@ -1418,11 +1418,16 @@ If this option is enabled, serialization groups can be defined using annotations
For more information, see :ref:`serializer-using-serialization-groups-annotations`.
+.. _reference-serializer-name_converter:
+
name_converter
..............
**type**: ``string``
+.. versionadded:: 2.8
+ The ``name_converter`` option was introduced in Symfony 2.8.
+
The name converter to use.
The :class:`Symfony\\Component\\Serializer\\NameConverter\\CamelCaseToSnakeCaseNameConverter`
name converter can enabled by using the ``serializer.name_converter.camel_case_to_snake_case``
diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst
index 211fb0a3753..7d03f107aa9 100644
--- a/reference/constraints/UniqueEntity.rst
+++ b/reference/constraints/UniqueEntity.rst
@@ -132,7 +132,18 @@ message
**type**: ``string`` **default**: ``This value is already used.``
-The message that's displayed when this constraint fails.
+The message that's displayed when this constraint fails. This message is always
+mapped to the first field causing the violation, even when using multiple fields
+in the constraint.
+
+.. versionadded:: 3.1
+ The ability to include the invalid value into the message was introduced
+ in Symfony 3.1.
+
+Messages can include the ``{{ value }}`` placeholder to display a string
+representation of the invalid entity. If the entity doesn't define the
+``__toString()`` method, the following generic value will be used: *"Object of
+class __CLASS__ identified by "*
em
~~
diff --git a/routing.rst b/routing.rst
index 7285148f4eb..074f10320c0 100644
--- a/routing.rst
+++ b/routing.rst
@@ -120,7 +120,7 @@ Thanks to these two routes:
* If the user goes to ``/blog/*``, the second route is matched and ``showAction()``
is executed. Because the route path is ``/blog/{slug}``, a ``$slug`` variable is
- passed to ``showAction`` matching that value. For example, if the user goes to
+ passed to ``showAction()`` matching that value. For example, if the user goes to
``/blog/yay-routing``, then ``$slug`` will equal ``yay-routing``.
Whenever you have a ``{placeholder}`` in your route path, that portion becomes a
@@ -363,7 +363,7 @@ With all of this in mind, check out this advanced example:
{
/**
* @Route(
- * "/articles/{_locale}/{year}/{title}.{_format}",
+ * "/articles/{_locale}/{year}/{slug}.{_format}",
* defaults={"_format": "html"},
* requirements={
* "_locale": "en|fr",
@@ -372,7 +372,7 @@ With all of this in mind, check out this advanced example:
* }
* )
*/
- public function showAction($_locale, $year, $title)
+ public function showAction($_locale, $year, $slug)
{
}
}
@@ -381,7 +381,7 @@ With all of this in mind, check out this advanced example:
# app/config/routing.yml
article_show:
- path: /articles/{_locale}/{year}/{title}.{_format}
+ path: /articles/{_locale}/{year}/{slug}.{_format}
defaults: { _controller: AppBundle:Article:show, _format: html }
requirements:
_locale: en|fr
@@ -398,7 +398,7 @@ With all of this in mind, check out this advanced example:
http://symfony.com/schema/routing/routing-1.0.xsd">
+ path="/articles/{_locale}/{year}/{slug}.{_format}">
AppBundle:Article:showhtml
@@ -418,7 +418,7 @@ With all of this in mind, check out this advanced example:
$collection = new RouteCollection();
$collection->add(
'article_show',
- new Route('/articles/{_locale}/{year}/{title}.{_format}', array(
+ new Route('/articles/{_locale}/{year}/{slug}.{_format}', array(
'_controller' => 'AppBundle:Article:show',
'_format' => 'html',
), array(
@@ -509,11 +509,11 @@ The pattern has three parts, each separated by a colon:
For example, a ``_controller`` value of ``AppBundle:Blog:show`` means:
-============= ================== ==============
+============= ================== ================
Bundle Controller Class Method Name
-============= ================== ==============
-``AppBundle`` ``BlogController`` ``showAction``
-============= ================== ==============
+============= ================== ================
+``AppBundle`` ``BlogController`` ``showAction()``
+============= ================== ================
The controller might look like this::
@@ -531,7 +531,7 @@ The controller might look like this::
}
Notice that Symfony adds the string ``Controller`` to the class name (``Blog``
-=> ``BlogController``) and ``Action`` to the method name (``show`` => ``showAction``).
+=> ``BlogController``) and ``Action`` to the method name (``show`` => ``showAction()``).
You could also refer to this controller using its fully-qualified class name
and method: ``AppBundle\Controller\BlogController::showAction``. But if you
diff --git a/serializer.rst b/serializer.rst
index be257084458..4b8331d1939 100644
--- a/serializer.rst
+++ b/serializer.rst
@@ -225,9 +225,12 @@ A service leveraging `APCu`_ (and APC for PHP < 5.5) is built-in.
Enabling a Name Converter
-------------------------
+.. versionadded:: 2.8
+ The ``name_converter`` option was introduced in Symfony 2.8.
+
The use of a :ref:`name converter `
-service can be defined in the configuration using the ``name_converter``
-serializer parameter.
+service can be defined in the configuration using the :ref:`name_converter `
+option.
The built-in :ref:`CamelCase to snake_case name converter `
can be enabled by using the ``serializer.name_converter.camel_case_to_snake_case``
diff --git a/service_container/service_decoration.rst b/service_container/service_decoration.rst
index 4bfdbd1f026..d94f155933b 100644
--- a/service_container/service_decoration.rst
+++ b/service_container/service_decoration.rst
@@ -18,7 +18,7 @@ the original service is lost:
# this replaces the old app.mailer definition with the new one, the
# old definition is lost
app.mailer:
- class AppBundle\DecoratingMailer
+ class: AppBundle\DecoratingMailer
.. code-block:: xml
diff --git a/setup.rst b/setup.rst
index 3db9aa62850..b8b94212de9 100644
--- a/setup.rst
+++ b/setup.rst
@@ -96,6 +96,9 @@ optional second argument of the ``new`` command:
# use the most recent 'lts' version (Long Term Support version)
$ symfony new my_project_name lts
+Each version has its *own* documentation, which you can select on any documentation
+page.
+
.. note::
Read the :doc:`Symfony Release process `
@@ -294,7 +297,7 @@ Go Deeper with Setup
.. _`Phar extension`: http://php.net/manual/en/intro.phar.php
.. _`Symfony Standard Edition`: https://github.com/symfony/symfony-standard
.. _`The Symfony Demo application`: https://github.com/symfony/symfony-demo
-.. _`The Symfony CMF Standard Edition`: https://github.com/symfony-cmf/symfony-cmf-standard
+.. _`The Symfony CMF Standard Edition`: https://github.com/symfony-cmf/standard-edition
.. _`Symfony CMF`: http://cmf.symfony.com/
.. _`The Symfony REST Edition`: https://github.com/gimler/symfony-rest-edition
.. _`FOSRestBundle`: https://github.com/FriendsOfSymfony/FOSRestBundle
diff --git a/setup/bundles.rst b/setup/bundles.rst
index 35bc6fcc60c..da8c119d5f9 100644
--- a/setup/bundles.rst
+++ b/setup/bundles.rst
@@ -189,6 +189,13 @@ adding a ``setDefined()`` method. The recommended check in this case would be::
// code for the new OptionsResolver API
}
+.. tip::
+
+ There is one case when you actually can rely on the
+ ``Symfony\Component\HttpKernel\Kernel::VERSION_ID`` constant: when trying
+ to detect the version of the ``symfony/http-kernel`` component, because it
+ is the component where this constant is defined.
+
.. _`symfony/phpunit-bridge package`: https://github.com/symfony/phpunit-bridge
.. _`Official Symfony Guide to Upgrade from 2.x to 3.0`: https://github.com/symfony/symfony/blob/2.8/UPGRADE-3.0.md
.. _`SensioLabs DeprecationDetector`: https://github.com/sensiolabs-de/deprecation-detector
diff --git a/templating.rst b/templating.rst
index 7e6ad161575..b9677bffb21 100644
--- a/templating.rst
+++ b/templating.rst
@@ -571,10 +571,10 @@ Creating links to other pages in your application is one of the most common
jobs for a template. Instead of hardcoding URLs in templates, use the ``path``
Twig function (or the ``router`` helper in PHP) to generate URLs based on
the routing configuration. Later, if you want to modify the URL of a particular
-page, all you'll need to do is change the routing configuration; the templates
+page, all you'll need to do is change the routing configuration: the templates
will automatically generate the new URL.
-First, link to the "_welcome" page, which is accessible via the following routing
+First, link to the "welcome" page, which is accessible via the following routing
configuration:
.. configuration-block::
@@ -589,7 +589,7 @@ configuration:
class WelcomeController extends Controller
{
/**
- * @Route("/", name="_welcome")
+ * @Route("/", name="welcome")
*/
public function indexAction()
{
@@ -600,7 +600,7 @@ configuration:
.. code-block:: yaml
# app/config/routing.yml
- _welcome:
+ welcome:
path: /
defaults: { _controller: AppBundle:Welcome:index }
@@ -613,7 +613,7 @@ configuration:
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">
-
+ AppBundle:Welcome:index
@@ -625,7 +625,7 @@ configuration:
use Symfony\Component\Routing\RouteCollection;
$collection = new RouteCollection();
- $collection->add('_welcome', new Route('/', array(
+ $collection->add('welcome', new Route('/', array(
'_controller' => 'AppBundle:Welcome:index',
)));
@@ -637,11 +637,11 @@ To link to the page, just use the ``path`` Twig function and refer to the route:
.. code-block:: html+twig
- Home
+ Home
.. code-block:: html+php
- Home
+ Home
As expected, this will generate the URL ``/``. Now, for a more complicated
route:
@@ -702,7 +702,7 @@ route:
In this case, you need to specify both the route name (``article_show``) and
a value for the ``{slug}`` parameter. Using this route, revisit the
-``recent_list`` template from the previous section and link to the articles
+``recent_list.html.twig`` template from the previous section and link to the articles
correctly:
.. configuration-block::
@@ -735,12 +735,12 @@ correctly:
.. code-block:: html+twig
- Home
+ Home
.. code-block:: html+php
Home
@@ -895,14 +895,14 @@ block of the base template.
You can also include assets located in your bundles' ``Resources/public`` folder.
You will need to run the ``php bin/console assets:install target [--symlink]``
-command, which moves (or symlinks) files into the correct location. (target
+command, which copies (or symlinks) files into the correct location. (target
is by default "web").
.. code-block:: html+twig
-The end result is a page that includes both the ``main.css`` and ``contact.css``
+The end result is a page that includes ``main.js`` and both the ``main.css`` and ``contact.css``
stylesheets.
Referencing the Request, User or Session
@@ -924,7 +924,7 @@ Suppose ``description`` equals ``I <3 this product``:
.. code-block:: twig
- {{ description }}
+ {{ description }}
{{ description|raw }}
diff --git a/translation/debug.rst b/translation/debug.rst
index 0ce77f1be5d..5ff68533669 100644
--- a/translation/debug.rst
+++ b/translation/debug.rst
@@ -15,21 +15,21 @@ tag or filter usages in Twig templates:
.. code-block:: jinja
- {% trans %}Symfony2 is great{% endtrans %}
+ {% trans %}Symfony is great{% endtrans %}
- {{ 'Symfony2 is great'|trans }}
+ {{ 'Symfony is great'|trans }}
- {{ 'Symfony2 is great'|transchoice(1) }}
+ {{ 'Symfony is great'|transchoice(1) }}
- {% transchoice 1 %}Symfony2 is great{% endtranschoice %}
+ {% transchoice 1 %}Symfony is great{% endtranschoice %}
It will also detect the following translator usages in PHP templates:
.. code-block:: php
- $view['translator']->trans("Symfony2 is great");
+ $view['translator']->trans("Symfony is great");
- $view['translator']->transChoice('Symfony2 is great', 1);
+ $view['translator']->transChoice('Symfony is great', 1);
.. caution::
@@ -41,7 +41,7 @@ It will also detect the following translator usages in PHP templates:
.. code-block:: jinja
- {% set message = 'Symfony2 is great' %}
+ {% set message = 'Symfony is great' %}
{{ message|trans }}
Suppose your application's default_locale is ``fr`` and you have configured
@@ -59,8 +59,8 @@ you've already setup some translations for the ``fr`` locale inside an AcmeDemoB
- Symfony2 is great
- J'aime Symfony2
+ Symfony is great
+ J'aime Symfony
@@ -70,13 +70,13 @@ you've already setup some translations for the ``fr`` locale inside an AcmeDemoB
.. code-block:: yaml
# src/Acme/AcmeDemoBundle/Resources/translations/messages.fr.yml
- Symfony2 is great: J'aime Symfony2
+ Symfony is great: J'aime Symfony
.. code-block:: php
// src/Acme/AcmeDemoBundle/Resources/translations/messages.fr.php
return array(
- 'Symfony2 is great' => 'J\'aime Symfony2',
+ 'Symfony is great' => 'J\'aime Symfony',
);
and for the ``en`` locale:
@@ -91,8 +91,8 @@ and for the ``en`` locale:
- Symfony2 is great
- Symfony2 is great
+ Symfony is great
+ Symfony is great
@@ -101,13 +101,13 @@ and for the ``en`` locale:
.. code-block:: yaml
# src/Acme/AcmeDemoBundle/Resources/translations/messages.en.yml
- Symfony2 is great: Symfony2 is great
+ Symfony is great: Symfony is great
.. code-block:: php
// src/Acme/AcmeDemoBundle/Resources/translations/messages.en.php
return array(
- 'Symfony2 is great' => 'Symfony2 is great',
+ 'Symfony is great' => 'Symfony is great',
);
To inspect all messages in the ``fr`` locale for the AcmeDemoBundle, run:
@@ -125,7 +125,7 @@ It shows you a table with the result when translating the message in the ``fr``
locale and the result when the fallback locale ``en`` would be used. On top
of that, it will also show you when the translation is the same as the fallback
translation (this could indicate that the message was not correctly translated).
-Furthermore, it indicates that the message ``Symfony2 is great`` is unused
+Furthermore, it indicates that the message ``Symfony is great`` is unused
because it is translated, but you haven't used it anywhere yet.
Now, if you translate the message in one of your templates, you will get this
@@ -137,7 +137,7 @@ output:
The state is empty which means the message is translated in the ``fr`` locale
and used in one or more templates.
-If you delete the message ``Symfony2 is great`` from your translation file
+If you delete the message ``Symfony is great`` from your translation file
for the ``fr`` locale and run the command, you will get:
.. image:: /_images/translation/debug_3.png