Skip to content

Commit 327ee85

Browse files
committed
Merge branch '2.8' into 3.2
* 2.8: [#7939] revert some changes (revert them for 3.2) Minor reword Update twig_reference.rst [#7958] fix minor typo improve examples of how we create test doubles Minor reword Add default indication in input arguments/options description Improved the explanation about deployment + parameters.yml Explained how to run tests in multiple kernel apps Fixed the explanation about PHPUnit event listeners in PHPUnitBridge File example update [#8003] add XML and PHP config examples Reworded the help note adding note that CSRF protection has to be enabled in config follow best practices for template files Added a note about disabling FastCGI buffering in Nginx Add some doc on missing options of framework bundle configuration Reworded the explanation about the --router option
2 parents 739f948 + 82f28b4 commit 327ee85

File tree

17 files changed

+197
-67
lines changed

17 files changed

+197
-67
lines changed

components/http_foundation.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,12 @@ represented by a PHP callable instead of a string::
461461
you must call ``ob_flush()`` before ``flush()``.
462462

463463
Additionally, PHP isn't the only layer that can buffer output. Your web
464-
server might also buffer based on its configuration. What's more, if you
465-
use FastCGI, buffering can't be disabled at all.
464+
server might also buffer based on its configuration. Some servers, such as
465+
Nginx, let you disable buffering at config level or adding a special HTTP
466+
header in the response::
467+
468+
// disables FastCGI buffering in Nginx only for this response
469+
$response->headers->set('X-Accel-Buffering', 'no')
466470

467471
.. _component-http-foundation-serving-files:
468472

components/phpunit_bridge.rst

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,16 @@ to register a new `test listener`_ called ``SymfonyTestsListener``:
5656
Usage
5757
-----
5858

59-
Once the component is installed, it automatically registers a
60-
`PHPUnit event listener`_ which in turn registers a `PHP error handler`_
61-
called :class:`Symfony\\Bridge\\PhpUnit\\DeprecationErrorHandler`. After
62-
running your PHPUnit tests, you will get a report similar to this one:
59+
Once the component is installed, a ``simple-phpunit`` script is created in the
60+
``vendor/`` directory to run tests. This script wraps the original PHPUnit binary
61+
to provide more features:
62+
63+
.. code-block:: terminal
64+
65+
$ cd my-project/
66+
$ ./vendor/bin/simple-phpunit
67+
68+
After running your PHPUnit tests, you will get a report similar to this one:
6369

6470
.. image:: /_images/components/phpunit_bridge/report.png
6571

@@ -76,6 +82,21 @@ The summary includes:
7682
Deprecation notices are all other (non-legacy) notices, grouped by message,
7783
test class and method.
7884

85+
.. note::
86+
87+
If you don't want to use the ``simple-phpunit`` script, register the following
88+
`PHPUnit event listener`_ in your PHPUnit configuration file to get the same
89+
report about deprecations (which is created by a `PHP error handler`_
90+
called :class:`Symfony\\Bridge\\PhpUnit\\DeprecationErrorHandler`):
91+
92+
.. code-block:: xml
93+
94+
<!-- phpunit.xml.dist -->
95+
<!-- ... -->
96+
<listeners>
97+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
98+
</listeners>
99+
79100
Trigger Deprecation Notices
80101
---------------------------
81102

configuration/multiple_kernels.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,43 @@ In order to solve this issue, add the following configuration to your kernel:
178178
# allows to use app/Resources/views/ templates in the ApiKernel
179179
"%kernel.root_dir%/../app/Resources/views": ~
180180
181+
Running Tests Using a Different Kernel
182+
--------------------------------------
183+
184+
In Symfony applications, functional tests extend by default from the
185+
:class:`Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase` class. Inside that
186+
class, a method called ``getKernelClass()`` tries to find the class of the kernel
187+
to use to run the application during tests. The logic of this method does not
188+
support multiple kernel applications, so your tests won't use the right kernel.
189+
190+
The solution is to create a custom base class for functional tests extending
191+
from ``WebTestCase`` class and overriding the ``getKernelClass()`` method to
192+
return the fully qualified class name of the kernel to use::
193+
194+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
195+
196+
// tests needing the ApiKernel to work, now must extend this
197+
// ApiTestCase class instead of the default WebTestCase class
198+
class ApiTestCase extends WebTestCase
199+
{
200+
protected static function getKernelClass()
201+
{
202+
return 'ApiKernel';
203+
}
204+
205+
// this is needed because the KernelTestCase class keeps a reference to
206+
// the previously created kernel in its static $kernel property. Thus,
207+
// if your functional tests do not run in isolated processes, a later run
208+
// test for a different kernel will reuse the previously created instance,
209+
// which points to a different kernel
210+
protected function tearDown()
211+
{
212+
parent::tearDown();
213+
214+
static::$class = null;
215+
}
216+
}
217+
181218
Adding more Kernels to the Application
182219
--------------------------------------
183220

console/input.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ There are three argument variants you can use:
9191
provided;
9292

9393
``InputArgument::OPTIONAL``
94-
The argument is optional and therefore can be omitted;
94+
The argument is optional and therefore can be omitted. This is the default
95+
behavior of arguments;
9596

9697
``InputArgument::IS_ARRAY``
9798
The argument can contain any number of values. For that reason, it must be
98-
used at the end of the argument list
99+
used at the end of the argument list.
99100

100101
You can combine ``IS_ARRAY`` with ``REQUIRED`` and ``OPTIONAL`` like this::
101102

@@ -177,11 +178,15 @@ There are four option variants you can use:
177178

178179
``InputOption::VALUE_IS_ARRAY``
179180
This option accepts multiple values (e.g. ``--dir=/foo --dir=/bar``);
181+
180182
``InputOption::VALUE_NONE``
181-
Do not accept input for this option (e.g. ``--yell``);
183+
Do not accept input for this option (e.g. ``--yell``). This is the default
184+
behavior of options;
185+
182186
``InputOption::VALUE_REQUIRED``
183187
This value is required (e.g. ``--iterations=5``), the option itself is
184188
still optional;
189+
185190
``InputOption::VALUE_OPTIONAL``
186191
This option may or may not have a value (e.g. ``--yell`` or
187192
``--yell=loud``).

controller/service.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Symfony's base controller::
174174
public function indexAction($name)
175175
{
176176
return $this->render(
177-
'@App/Hello/index.html.twig',
177+
'hello/index.html.twig',
178178
array('name' => $name)
179179
);
180180
}
@@ -210,7 +210,7 @@ service and use it directly::
210210
public function indexAction($name)
211211
{
212212
return $this->templating->renderResponse(
213-
'@App/Hello/index.html.twig',
213+
'hello/index.html.twig',
214214
array('name' => $name)
215215
);
216216
}

deployment.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,20 @@ Check if your server meets the requirements by running:
120120
121121
$ php bin/symfony_requirements
122122
123-
B) Configure your ``app/config/parameters.yml`` File
124-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123+
.. _b-configure-your-app-config-parameters-yml-file:
125124

126-
This file should *not* be deployed, but managed through the automatic utilities
127-
provided by Symfony.
125+
B) Configure your Parameters File
126+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127+
128+
Most Symfony applications define configuration parameters in a file called
129+
``app/config/parameters.yml``. This file should *not* be deployed, because
130+
Symfony generates it automatically using the ``app/config/parameters.yml.dist``
131+
file as a template (that's why ``parameters.yml.dist`` must be committed and
132+
deployed).
133+
134+
If your application uses environment variables instead of these parameters, you
135+
must define those env vars in your production server using the tools provided by
136+
your hosting service.
128137

129138
C) Install/Update your Vendors
130139
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

form/direct_submit.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ submissions::
2424
return $this->redirectToRoute('task_success');
2525
}
2626

27-
return $this->render('@App/Default/new.html.twig', array(
27+
return $this->render('default/new.html.twig', array(
2828
'form' => $form->createView(),
2929
));
3030
}
@@ -63,7 +63,7 @@ method, pass the submitted data directly to
6363
}
6464
}
6565

66-
return $this->render('@App/Default/new.html.twig', array(
66+
return $this->render('default/new.html.twig', array(
6767
'form' => $form->createView(),
6868
));
6969
}

form/dynamic_form_modification.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ your application. Assume that you have a sport meetup creation controller::
565565
}
566566

567567
return $this->render(
568-
'@App/Meetup/create.html.twig',
568+
'meetup/create.html.twig',
569569
array('form' => $form->createView())
570570
);
571571
}
@@ -580,7 +580,7 @@ field according to the current selection in the ``sport`` field:
580580

581581
.. code-block:: html+twig
582582

583-
{# app/Resources/views/Meetup/create.html.twig #}
583+
{# app/Resources/views/meetup/create.html.twig #}
584584
{{ form_start(form) }}
585585
{{ form_row(form.sport) }} {# <select id="meetup_sport" ... #}
586586
{{ form_row(form.position) }} {# <select id="meetup_position" ... #}

form/form_collections.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ In your controller, you'll create a new form from the ``TaskType``::
177177
// ... maybe do some form processing, like saving the Task and Tag objects
178178
}
179179

180-
return $this->render('@App/Task/new.html.twig', array(
180+
return $this->render('task/new.html.twig', array(
181181
'form' => $form->createView(),
182182
));
183183
}
@@ -193,7 +193,7 @@ zero tags when first created).
193193

194194
.. code-block:: html+twig
195195

196-
{# src/AppBundle/Resources/views/Task/new.html.twig #}
196+
{# app/Resources/views/task/new.html.twig #}
197197

198198
{# ... #}
199199

profiler/data_collector.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ block and set the value of two variables called ``icon`` and ``text``:
197197

198198
.. code-block:: twig
199199
200-
{{ include('@App/data_collector/icon.svg') }}
200+
{{ include('data_collector/icon.svg') }}
201201
202202
You are encouraged to use the latter technique for your own toolbar panels.
203203

reference/configuration/framework.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ Configuration
6464
* `gc_divisor`_
6565
* `gc_probability`_
6666
* `gc_maxlifetime`_
67+
* `use_strict_mode`_
6768
* `save_path`_
69+
* `metadata_update_threshold`_
6870
* `assets`_
6971
* `base_path`_
7072
* `base_urls`_
@@ -793,6 +795,17 @@ This determines the number of seconds after which data will be seen as "garbage"
793795
and potentially cleaned up. Garbage collection may occur during session
794796
start and depends on `gc_divisor`_ and `gc_probability`_.
795797

798+
use_strict_mode
799+
...............
800+
801+
**type**: ``boolean`` **default**: ``false``
802+
803+
This specifies whether the session module will use the strict session id mode.
804+
If this mode is enabled, the module does not accept uninitialized session IDs.
805+
If an uninitialized session ID is sent from browser, a new session ID is sent
806+
to browser. Applications are protected from session fixation via session
807+
adoption with strict mode.
808+
796809
save_path
797810
.........
798811

@@ -839,6 +852,19 @@ setting the value to ``null``:
839852
),
840853
));
841854
855+
metadata_update_threshold
856+
.........................
857+
858+
**type**: ``integer`` **default**: ``0``
859+
860+
This is how many seconds to wait between two session metadata updates. It will
861+
also prevent the session handler to write if the session has not changed.
862+
863+
.. seealso::
864+
865+
You can see an example of the usage of this in
866+
:doc:`/session/limit_metadata_writes`.
867+
842868
assets
843869
~~~~~~
844870

reference/configuration/twig.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ TwigBundle Configuration ("twig")
2525
- foundation_5_layout.html.twig
2626
2727
# Example:
28-
- @App/form.html.twig
28+
- form.html.twig
2929
3030
globals:
3131
@@ -77,7 +77,7 @@ TwigBundle Configuration ("twig")
7777
optimizations="true"
7878
>
7979
<twig:form-theme>form_div_layout.html.twig</twig:form-theme> <!-- Default -->
80-
<twig:form-theme>@App/form.html.twig</twig:form-theme>
80+
<twig:form-theme>form.html.twig</twig:form-theme>
8181
8282
<twig:global key="foo" id="bar" type="service" />
8383
<twig:global key="pi">3.14</twig:global>
@@ -93,7 +93,7 @@ TwigBundle Configuration ("twig")
9393
$container->loadFromExtension('twig', array(
9494
'form_themes' => array(
9595
'form_div_layout.html.twig', // Default
96-
'@App/form.html.twig',
96+
'form.html.twig',
9797
),
9898
'globals' => array(
9999
'foo' => '@bar',

reference/forms/types/file.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ be used to move the ``attachment`` file to a permanent location::
5252
if ($form->isSubmitted() && $form->isValid()) {
5353
$someNewFilename = ...
5454

55-
$form['attachment']->getData()->move($dir, $someNewFilename);
55+
$file = $form['attachment']->getData();
56+
$file->move($dir, $someNewFilename);
5657

5758
// ...
5859
}

reference/twig_reference.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,14 @@ file_excerpt
567567

568568
.. code-block:: twig
569569
570-
{{ file|file_excerpt(line = null) }}
570+
{{ file|file_excerpt(line) }}
571571
572572
``file``
573573
**type**: ``string``
574-
``line`` *(optional)*
574+
``line``
575575
**type**: ``integer``
576576

577-
Generates an excerpt of seven lines around the given ``line``.
577+
Generates an excerpt of a code file around the given ``line`` number.
578578

579579
format_file
580580
~~~~~~~~~~~
@@ -611,12 +611,14 @@ file_link
611611

612612
.. code-block:: twig
613613
614-
{{ file|file_link(line = null) }}
614+
{{ file|file_link(line) }}
615615
616-
``line`` *(optional)*
616+
``file``
617+
**type**: ``string``
618+
``line``
617619
**type**: ``integer``
618620

619-
Generates a link to the provided file (and optionally line number) using
621+
Generates a link to the provided file and line number using
620622
a preconfigured scheme.
621623

622624
.. _reference-twig-tags:

0 commit comments

Comments
 (0)