8000 Merge branch '4.2' · symfony/symfony-docs@5aa9ee5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5aa9ee5

Browse files
committed
Merge branch '4.2'
* 4.2: remove the mention of .yml fix services file for older version More improvements of the Session article remove obsolete internal references use .yaml instead of .yml for examples
2 parents 3a43d42 + 9909560 commit 5aa9ee5

File tree

6 files changed

+80
-32
lines changed

6 files changed

+80
-32
lines changed

best_practices/configuration.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ and security credentials) and different environments (development, production).
66
That's why Symfony recommends that you split the application configuration into
77
three parts.
88

9-
.. _config-parameters.yml:
10-
119
Infrastructure-Related Configuration
1210
------------------------------------
1311

@@ -53,8 +51,6 @@ To override these variables with machine-specific or sensitive values, create a
5351
environment variables, exposing sensitive information such as the database
5452
credentials.
5553

56-
.. _best-practices-canonical-parameters:
57-
5854
Canonical Parameters
5955
~~~~~~~~~~~~~~~~~~~~
6056

configuration/configuration_organization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Mix and Match Configuration Formats
7878
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7979

8080
Configuration files can import files defined with any other built-in configuration
81-
format (``.yaml`` or ``.yml``, ``.xml``, ``.php``, ``.ini``):
81+
format (``.yaml``, ``.xml``, ``.php``, ``.ini``):
8282

8383
.. configuration-block::
8484

reference/configuration/framework.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ type
725725

726726
The type of the resource to hint the loaders about the format. This isn't
727727
needed when you use the default routers with the expected file extensions
728-
(``.xml``, ``.yml`` or ``.yaml``, ``.php``).
728+
(``.xml``, ``.yaml``, ``.php``).
729729

730730
http_port
731731
.........
@@ -792,18 +792,15 @@ alias will be set to this service id. This class has to implement
792792
handler_id
793793
..........
794794

795-
**type**: ``string`` **default**: ``'session.handler.native_file'``
796-
797-
The service id used for session storage. The ``session.handler`` service
798-
alias will be set to this service id.
799-
800-
You can also set it to ``null``, to default to the handler of your PHP
801-
installation.
795+
**type**: ``string`` **default**: ``null``
802796

803-
.. seealso::
797+
The service id used for session storage. The default ``null`` value means to use
798+
the native PHP session mechanism. Set it to ``'session.handler.native_file'`` to
799+
let Symfony manage the sessions itself using files to store the session
800+
metadata.
804801

805-
You can see an example of the usage of this in
806-
:doc:`/doctrine/pdo_session_storage`.
802+
If you prefer to make Symfony store sessions in a database read
803+
:doc:`/doctrine/pdo_session_storage`.
807804

808805
.. _name:
809806

routing/external_resources.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This can be done by importing routing resources from the main routing file:
1919
# config/routes.yaml
2020
app_file:
2121
# loads routes from the given routing file stored in some bundle
22-
resource: '@AcmeOtherBundle/Resources/config/routing.yml'
22+
resource: '@AcmeOtherBundle/Resources/config/routing.yaml'
2323
2424
app_annotations:
2525
# loads routes from the PHP annotations of the controllers found in that directory
@@ -46,7 +46,7 @@ This can be done by importing routing resources from the main routing file:
4646
http://symfony.com/schema/routing/routing-1.0.xsd">
4747
4848
<!-- loads routes from the given routing file stored in some bundle -->
49-
<import resource="@AcmeOtherBundle/Resources/config/routing.yml" />
49+
<import resource="@AcmeOtherBundle/Resources/config/routing.yaml" />
5050
5151
<!-- loads routes from the PHP annotations of the controllers found in that directory -->
5252
<import resource="../src/Controller/" type="annotation" />
@@ -66,7 +66,7 @@ This can be done by importing routing resources from the main routing file:
6666
$routes = new RouteCollection();
6767
$routes->addCollection(
6868
// loads routes from the given routing file stored in some bundle
69-
$loader->import("@AcmeOtherBundle/Resources/config/routing.yml")
69+
$loader->import("@AcmeOtherBundle/Resources/config/routing.yaml")
7070
7171
// loads routes from the PHP annotations of the controllers found in that directory
7272
$loader->import("../src/Controller/", "annotation")

service_container.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,5 @@ Learn more
10821082
/service_container/*
10831083

10841084
.. _`service-oriented architecture`: https://en.wikipedia.org/wiki/Service-oriented_architecture
1085-
.. _`Symfony Standard Edition (version 3.3) services.yaml`: https://github.com/symfony/symfony-standard/blob/3.3/app/config/services.yml
10861085
.. _`glob pattern`: https://en.wikipedia.org/wiki/Glob_(programming)
10871086
.. _`Symfony Fundamentals screencast series`: https://symfonycasts.com/screencast/symfony-fundamentals

session.rst

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Configuration
99

1010
Sessions are provided by the `HttpFoundation component`_, which is included in
1111
all Symfony applications, no matter how you installed it. Before using the
12-
sessions, check their configuration:
12+
sessions, check their default configuration:
1313

1414
.. configuration-block::
1515

@@ -20,12 +20,12 @@ sessions, check their configuration:
2020
session:
2121
# enables the support of sessions in the app
2222
enabled: true
23-
24-
# ID of the service used for session storage
25-
handler_id: session.handler.native_file
26-
27-
# the directory where session metadata is stored
28-
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
23+
# ID of the service used for session storage.
24+
# NULL = means that PHP's default session mechanism is used
25+
handler_id: null
26+
# improves the security of the cookies used for sessions
27+
cookie_secure: 'auto'
28+
cookie_samesite: 'lax'
2929
3030
.. code-block:: xml
3131
@@ -42,11 +42,13 @@ sessions, check their configuration:
4242
<!--
4343
enabled: enables the support of sessions in the app
4444
handler-id: ID of the service used for session storage
45-
save_path: the directory where session metadata is stored
45+
NULL means that PHP's default session mechanism is used
46+
cookie-secure and cookie-samesite: improves the security of the cookies used for sessions
4647
-->
4748
<framework:session enabled="true"
48-
handler-id="session.handler.native_file"
49-
save-path="%kernel.project_dir%/var/sessions/%kernel.environment%" />
49+
handler-id="null"
50+
cookie-secure="auto"
51+
cookie-samesite="lax" />
5052
</framework:config>
5153
</container>
5254
@@ -58,15 +60,69 @@ sessions, check their configuration:
5860
// enables the support of sessions in the app
5961
'enabled' => true,
6062
// ID of the service used for session storage
63+
// NULL means that PHP's default session mechanism is used
64+
'handler_id' => null,
65+
// improves the security of the cookies used for sessions
66+
'cookie_secure' => 'auto',
67+
'cookie_samesite' => 'lax',
68+
],
69+
]);
70+
71+
Setting the ``handler_id`` config option to ``null`` means that Symfony will
72+
use the native PHP session mechanism. The session metadata files will be stored
73+
outside of the Symfony application, in a directory controlled by PHP. Although
74+
this usually simplify things, some session expiration related options may no
75+
work as expected if other applications that write to the same directory have
76+
short max lifetime settings.
77+
78+
If you prefer, you can use the ``session.handler.native_file`` service as
79+
``handler_id`` to let Symfony manage the sessions itself. Another useful option
80+
is ``save_path``, which defines the directory where Symfony will store the
81+
session metadata files:
82+
83+
.. configuration-block::
84+
85+
.. code-block:: yaml
86+
87+
# config/packages/framework.yaml
88+
framework:
89+
session:
90+
# ...
91+
handler_id: 'session.handler.native_file'
92+
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
93+
94+
.. code-block:: xml
95+
96+
<!-- config/packages/framework.xml -->
97+
<?xml version="1.0" encoding="UTF-8" ?>
98+
<container xmlns="http://symfony.com/schema/dic/services"
99+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
100+
xmlns:framework="http://symfony.com/schema/dic/symfony"
101+
xsi:schemaLocation="http://symfony.com/schema/dic/services
102+
http://symfony.com/schema/dic/services/services-1.0.xsd
103+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
104+
105+
<framework:config>
106+
<framework:session enabled="true"
107+
handler-id="session.handler.native_file"
108+
save-path="%kernel.project_dir%/var/sessions/%kernel.environment%" />
109+
</framework:config>
110+
</container>
111+
112+
.. code-block:: php
113+
114+
// config/packages/framework.php
115+
$container->loadFromExtension('framework', [
116+
'session' => [
117+
// ...
61118
'handler_id' => 'session.handler.native_file',
62-
// the directory where session metadata is stored
63119
'save_path' => '%kernel.project_dir%/var/sessions/%kernel.environment%',
64120
],
65121
]);
66122
67123
Check out the Symfony config reference to learn more about the other available
68124
:ref:`Session configuration options <config-framework-session>`. Also, if you
69-
prefer to store session metadata in the database instead of the filesystem,
125+
prefer to store session metadata in a database instead of the filesystem,
70126
check out this article: :doc:`/doctrine/pdo_session_storage`.
71127

72128
Basic Usage

0 commit comments

Comments
 (0)
0