Skip to content

Commit 664f280

Browse files
authored
Merge branch '4.0' into update_http_cache
2 parents d512875 + c4707d1 commit 664f280

File tree

159 files changed

+2975
-8541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+2975
-8541
lines changed

_build/redirection_map

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
/cookbook/bundles/installation /bundles
101101
/cookbook/bundles/override /bundles/override
102102
/cookbook/bundles/prepend_extension /bundles/prepend_extension
103-
/cookbook/bundles/remove /bundles/remove
103+
/cookbook/bundles/remove /bundles
104+
/bundles/remove /bundles
104105
/cookbook/cache/form_csrf_caching /http_cache/form_csrf_caching
105106
/cookbook/cache/varnish /http_cache/varnish
106107
/cookbook/composer /setup/composer
@@ -137,18 +138,21 @@
137138
/cookbook/deployment/platformsh /deployment/platformsh
138139
/cookbook/deployment/tools /deployment/tools
139140
/cookbook/doctrine/common_extensions /doctrine/common_extensions
140-
/cookbook/doctrine/console /doctrine/console
141+
/cookbook/doctrine/console /doctrine
141142
/cookbook/doctrine/custom_dql_functions /doctrine/custom_dql_functions
142143
/cookbook/doctrine/dbal /doctrine/dbal
143144
/cookbook/doctrine/event_listeners_subscribers /doctrine/event_listeners_subscribers
144145
/cookbook/doctrine/index /doctrine
145-
/cookbook/doctrine/mapping_model_classes /doctrine/mapping_model_classes
146+
/cookbook/doctrine/mapping_model_classes /doctrine
147+
/doctrine/mapping_model_classes /doctrine
146148
/cookbook/doctrine/mongodb_session_storage /doctrine/mongodb_session_storage
147149
/cookbook/doctrine/multiple_entity_managers /doctrine/multiple_entity_managers
148150
/cookbook/doctrine/pdo_session_storage /doctrine/pdo_session_storage
149151
/cookbook/doctrine/registration_form /doctrine/registration_form
150152
/cookbook/doctrine/resolve_target_entity /doctrine/resolve_target_entity
151153
/cookbook/doctrine/reverse_engineering /doctrine/reverse_engineering
154+
/doctrine/repository /doctrine
155+
/doctrine/console /doctrine
152156
/cookbook/email/cloud /email/cloud
153157
/cookbook/email/dev_environment /email/dev_environment
154158
/cookbook/email/email /email
@@ -282,7 +286,8 @@
282286
/cookbook/workflow/homestead /setup/homestead
283287
/cookbook/workflow/index /setup
284288
/cookbook/workflow/new_project_git /setup/new_project_git
285-
/cookbook/workflow/new_project_svn /setup/new_project_svn
289+
/cookbook/workflow/new_project_svn /setup/new_project_git
290+
/setup/new_project_svn /setup/new_project_git
286291
/components/asset/index /components/asset
287292
/components/asset/introduction /components/asset
288293
/components/browser_kit/index /components/browser_kit

best_practices/business-logic.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ were defined by the PHP community. You can learn more about
268268
use the `PHP-CS-Fixer`_, which is a command-line utility that can fix the
269269
coding standards of an entire codebase in a matter of seconds.
270270

271+
----
272+
273+
Next: :doc:`/best_practices/controllers`
274+
271275
.. _`full definition`: https://en.wikipedia.org/wiki/Business_logic
272276
.. _`Doctrine project`: http://www.doctrine-project.org/
273277
.. _`fixture class`: https://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html#writing-simple-fixtures

best_practices/configuration.rst

Lines changed: 38 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ three parts.
1111
Infrastructure-Related Configuration
1212
------------------------------------
1313

14+
These are the options that change from one machine to another (e.g. from your
15+
development machine to the production server) but which don't change the
16+
application behavior.
17+
1418
.. best-practice::
1519

16-
Define the infrastructure-related configuration options in the
17-
``app/config/parameters.yml`` file.
20+
Define the infrastructure-related configuration options as environment
21+
variables. During development, use the ``.env`` file at the root of your
22+
project to set these.
1823

19-
The default ``parameters.yml`` file follows this recommendation and defines the
20-
options related to the database and mail server infrastructure:
24+
By default, Symfony adds these types of options to the ``.env`` file when
25+
installing new dependencies in the app:
2126

22-
.. code-block:: yaml
27+
.. code-block:: bash
2328
24-
# app/config/parameters.yml
25-
parameters:
26-
database_driver: pdo_mysql
27-
database_host: 127.0.0.1
28-
database_port: ~
29-
database_name: symfony
30-
database_user: root
31-
database_password: ~
29+
# .env
30+
###> doctrine/doctrine-bundle ###
31+
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/blog.sqlite
32+
###< doctrine/doctrine-bundle ###
3233
33-
mailer_transport: smtp
34-
mailer_host: 127.0.0.1
35-
mailer_user: ~
36-
mailer_password: ~
34+
###> symfony/swiftmailer-bundle ###
35+
MAILER_URL=smtp://localhost?encryption=ssl&auth_mode=login&username=&password=
36+
###< symfony/swiftmailer-bundle ###
3737
38-
# ...
38+
# ...
3939
40-
These options aren't defined inside the ``app/config/config.yml`` file because
40+
These options aren't defined inside the ``config/services.yaml`` file because
4141
they have nothing to do with the application's behavior. In other words, your
4242
application doesn't care about the location of your database or the credentials
4343
to access to it, as long as the database is correctly configured.
@@ -49,37 +49,32 @@ Canonical Parameters
4949

5050
.. best-practice::
5151

52-
Define all your application's parameters in the
53-
``app/config/parameters.yml.dist`` file.
52+
Define all your application's env vars in the ``.env.dist`` file.
5453

55-
Symfony includes a configuration file called ``parameters.yml.dist``, which
56-
stores the canonical list of configuration parameters for the application.
54+
Symfony includes a configuration file called ``.env.dist`` at the project root,
55+
which stores the canonical list of environment variables for the application.
5756

58-
Whenever a new configuration parameter is defined for the application, you
59-
should also add it to this file and submit the changes to your version control
60-
system. Then, whenever a developer updates the project or deploys it to a server,
61-
Symfony will check if there is any difference between the canonical
62-
``parameters.yml.dist`` file and your local ``parameters.yml`` file. If there
63-
is a difference, Symfony will ask you to provide a value for the new parameter
64-
and it will add it to your local ``parameters.yml`` file.
57+
Whenever a new env var is defined for the application, you should also add it to
58+
this file and submit the changes to your version control system so your
59+
workmates can update their ``.env`` files.
6560

6661
Application-Related Configuration
6762
---------------------------------
6863

6964
.. best-practice::
7065

7166
Define the application behavior related configuration options in the
72-
``app/config/config.yml`` file.
67+
``config/services.yaml`` file.
7368

74-
The ``config.yml`` file contains the options used by the application to modify
75-
its behavior, such as the sender of email notifications, or the enabled
76-
`feature toggles`_. Defining these values in ``parameters.yml`` file would
77-
add an extra layer of configuration that's not needed because you don't need
78-
or want these configuration values to change on each server.
69+
The ``services.yaml`` file contains the options used by the application to
70+
modify its behavior, such as the sender of email notifications, or the enabled
71+
`feature toggles`_. Defining these values in ``.env`` file would add an extra
72+
layer of configuration that's not needed because you don't need or want these
73+
configuration values to change on each server.
7974

80-
The configuration options defined in the ``config.yml`` file usually vary from
81-
one :doc:`environment </configuration/environments>` to another. That's
82-
why Symfony already includes ``app/config/config_dev.yml`` and ``app/config/config_prod.yml``
75+
The configuration options defined in the ``services.yaml`` may vary from one
76+
:doc:`environment </configuration/environments>` to another. That's why Symfony
77+
supports defining ``config/services_dev.yaml`` and ``config/services_prod.yaml``
8378
files so that you can override specific values for each environment.
8479

8580
Constants vs Configuration Options
@@ -99,7 +94,7 @@ to control the number of posts to display on the blog homepage:
9994

10095
.. code-block:: yaml
10196
102-
# app/config/config.yml
97+
# config/services.yaml
10398
parameters:
10499
homepage.num_items: 10
105100
@@ -167,7 +162,7 @@ just one or two words to describe the purpose of the parameter:
167162

168163
.. code-block:: yaml
169164
170-
# app/config/config.yml
165+
# config/services.yaml
171166
parameters:
172167
# don't do this: 'dir' is too generic and it doesn't convey any meaning
173168
app.dir: '...'
@@ -178,37 +173,9 @@ just one or two words to describe the purpose of the parameter:
178173
app.dir.contents: '...'
179174
app.contents-dir: '...'
180175
181-
Semantic Configuration: Don't Do It
182-
-----------------------------------
183-
184-
.. best-practice::
185-
186-
Don't define a semantic dependency injection configuration for your bundles.
187-
188-
As explained in :doc:`/bundles/extension` article, Symfony bundles
189-
have two choices on how to handle configuration: normal service configuration
190-
through the ``services.yml`` file and semantic configuration through a special
191-
``*Extension`` class.
192-
193-
Although semantic configuration is much more powerful and provides nice features
194-
such as configuration validation, the amount of work needed to define that
195-
configuration isn't worth it for bundles that aren't meant to be shared as
196-
third-party bundles.
197-
198-
Moving Sensitive Options Outside of Symfony Entirely
199-
----------------------------------------------------
200-
201-
When dealing with sensitive options, like database credentials, we also recommend
202-
that you store them outside the Symfony project and make them available
203-
through environment variables:
204-
205-
.. code-block:: yaml
176+
----
206177

207-
# app/config/config.yml
208-
doctrine:
209-
dbal:
210-
# ...
211-
password: "%env(DB_PASSWORD)%"
178+
Next: :doc:`/best_practices/business-logic`
212179

213180
.. _`feature toggles`: https://en.wikipedia.org/wiki/Feature_toggle
214181
.. _`constant() function`: http://twig.sensiolabs.org/doc/functions/constant.html

best_practices/controllers.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,8 @@ If you need to execute some code before or after the execution of your controlle
237237
you can use the EventDispatcher component to
238238
:doc:`set up before and after filters </event_dispatcher/before_after_filters>`.
239239

240+
----
241+
242+
Next: :doc:`/best_practices/templates`
243+
240244
.. _`ParamConverter`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html

best_practices/creating-the-project.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Installing Symfony
88

99
Use Composer and Symfony Flex to create and manage Symfony applications.
1010

11-
`Composer`_ is the package manager used by modern PHP application to manage
11+
`Composer`_ is the package manager used by modern PHP applications to manage
1212
their dependencies. `Symfony Flex`_ is a Composer plugin designed to automate
1313
some of the most common tasks performed in Symfony applications. Using Flex is
1414
optional but recommended because it improves your productivity significantly.
@@ -91,6 +91,10 @@ Symfony applications can still use third-party bundles (installed in ``vendor/``
9191
to add features, but you should use PHP namespaces instead of bundles to organize
9292
your own code.
9393

94+
----
95+
96+
Next: :doc:`/best_practices/configuration`
97+
9498
.. _`Composer`: https://getcomposer.org/
9599
.. _`Symfony Flex`: https://github.com/symfony/flex
96100
.. _`Symfony Skeleton`: https://github.com/symfony/skeleton

best_practices/forms.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,5 @@ handling the form submit. For example, you *could* have a ``new()`` action that
192192
*only* renders the form and a ``create()`` action that *only* processes the form
193193
submit. Both those actions will be almost identical. So it's much simpler to let
194194
``new()`` handle everything.
195+
196+
Next: :doc:`/best_practices/i18n`

best_practices/i18n.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,8 @@ English in the application would be:
7676
</file>
7777
</xliff>
7878
79+
----
80+
81+
Next: :doc:`/best_practices/security`
82+
7983
.. _`JMSTranslationBundle`: https://github.com/schmittjoh/JMSTranslationBundle

best_practices/introduction.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,9 @@ for not doing it are various:
9898
* The amount of work spent on this could be better dedicated to improving
9999
your tests or adding features that provide real value to the end users.
100100

101+
----
102+
103+
Next: :doc:`/best_practices/creating-the-project`
104+
101105
.. _`Fabien Potencier`: https://connect.sensiolabs.com/profile/fabpot
102106
.. _`Symfony Demo`: https://github.com/symfony/demo

best_practices/security.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ If your company uses a user login method not supported by Symfony, you can
385385
develop :doc:`your own user provider </security/custom_provider>` and
386386
:doc:`your own authentication provider </security/custom_authentication_provider>`.
387387

388+
----
389+
390+
Next: :doc:`/best_practices/web-assets`
391+
388392
.. _`ParamConverter`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
389393
.. _`@Security annotation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html
390394
.. _`FOSUserBundle`: https://github.com/FriendsOfSymfony/FOSUserBundle

best_practices/templates.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,9 @@ If you're using the :ref:`default services.yaml configuration <service-container
116116
you're done! Symfony will automatically know about your new service and tag it to
117117
be used as a Twig extension.
118118

119+
----
120+
121+
Next: :doc:`/best_practices/forms`
122+
119123
.. _`Twig`: http://twig.sensiolabs.org/
120124
.. _`Parsedown`: http://parsedown.org/

best_practices/web-assets.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ the JavaScript-based tools used in modern web applications. Check out the
2525
`official Webpack Encore documentation`_ to learn more about all the available
2626
features.
2727

28+
----
29+
30+
Next: :doc:`/best_practices/tests`
31+
32+
.. _`official Assetic documentation`: https://github.com/kriswallsmith/assetic
2833
.. _`Webpack Encore`: https://github.com/symfony/webpack-encore
2934
.. _`Webpack`: https://webpack.js.org/
3035
.. _`official Webpack Encore documentation`: https://symfony.com/doc/current/frontend.html

bundles.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ file::
4444
Learn more
4545
----------
4646

47-
* :doc:`/bundles/remove`
4847
* :doc:`/bundles/override`
4948
* :doc:`/bundles/best_practices`
5049
* :doc:`/bundles/configuration`

0 commit comments

Comments
 (0)