Skip to content

Commit 5a41c07

Browse files
committed
Merge remote-tracking branch 'upstream/2.7' into 2.7
2 parents 44270ab + 0ae6a4c commit 5a41c07

18 files changed

+207
-73
lines changed

components/http_foundation.rst

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

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

474478
.. _component-http-foundation-serving-files:
475479

components/phpunit_bridge.rst

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ You can install the component in 2 different ways:
3737
Usage
3838
-----
3939

40-
Once the component is installed, it automatically registers a
41-
`PHPUnit event listener`_ which in turn registers a `PHP error handler`_
42-
called :class:`Symfony\\Bridge\\PhpUnit\\DeprecationErrorHandler`. After
43-
running your PHPUnit tests, you will get a report similar to this one:
40+
Once the component is installed, a ``simple-phpunit`` script is created in the
41+
``vendor/`` directory to run tests. This script wraps the original PHPUnit binary
42+
to provide more features:
43+
44+
.. code-block:: terminal
45+
46+
$ cd my-project/
47+
$ ./vendor/bin/simple-phpunit
48+
49+
After running your PHPUnit tests, you will get a report similar to this one:
4450

4551
.. image:: /_images/components/phpunit_bridge/report.png
4652

@@ -57,6 +63,21 @@ The summary includes:
5763
Deprecation notices are all other (non-legacy) notices, grouped by message,
5864
test class and method.
5965

66+
.. note::
67+
68+
If you don't want to use the ``simple-phpunit`` script, register the following
69+
`PHPUnit event listener`_ in your PHPUnit configuration file to get the same
70+
report about deprecations (which is created by a `PHP error handler`_
71+
called :class:`Symfony\\Bridge\\PhpUnit\\DeprecationErrorHandler`):
72+
73+
.. code-block:: xml
74+
75+
<!-- phpunit.xml.dist -->
76+
<!-- ... -->
77+
<listeners>
78+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
79+
</listeners>
80+
6081
Trigger Deprecation Notices
6182
---------------------------
6283

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
@@ -177,7 +177,7 @@ Symfony's base controller::
177177
public function indexAction($name)
178178
{
179179
return $this->render(
180-
'@App/Hello/index.html.twig',
180+
'hello/index.html.twig',
181181
array('name' => $name)
182182
);
183183
}
@@ -213,7 +213,7 @@ service and use it directly::
213213
public function indexAction($name)
214214
{
215215
return $this->templating->renderResponse(
216-
'@App/Hello/index.html.twig',
216+
'hello/index.html.twig',
217217
array('name' => $name)
218218
);
219219
}

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 app/check.php
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/create_custom_field_type.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ for form fields, which is ``<BundleName>\Form\Type``. Make sure the field extend
3535
'Standard Shipping' => 'standard',
3636
'Expedited Shipping' => 'expedited',
3737
'Priority Shipping' => 'priority',
38-
)
38+
),
39+
'choices_as_values' => true,
3940
));
4041
}
4142

@@ -395,6 +396,7 @@ method to ``ShippingType``, which receives the shipping configuration::
395396
{
396397
$resolver->setDefaults(array(
397398
'choices' => array_flip($this->shippingOptions),
399+
'choices_as_values' => true,
398400
));
399401
}
400402

form/direct_submit.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ submissions::
2828
return $this->redirectToRoute('task_success');
2929
}
3030

31-
return $this->render('@App/Default/new.html.twig', array(
31+
return $this->render('default/new.html.twig', array(
3232
'form' => $form->createView(),
3333
));
3434
}
@@ -67,7 +67,7 @@ method, pass the submitted data directly to
6767
}
6868
}
6969

70-
return $this->render('@App/Default/new.html.twig', array(
70+
return $this->render('default/new.html.twig', array(
7171
'form' => $form->createView(),
7272
));
7373
}
@@ -126,7 +126,7 @@ a convenient shortcut to the previous example::
126126
}
127127
}
128128

129-
return $this->render('@App/Default/new.html.twig', array(
129+
return $this->render('default/new.html.twig', array(
130130
'form' => $form->createView(),
131131
));
132132
}

form/dynamic_form_modification.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,10 @@ sport like this::
490490
$positions = null === $sport ? array() : $sport->getAvailablePositions();
491491

492492
$form->add('position', 'entity', array(
493-
'class' => 'AppBundle:Position',
493+
'class' => 'AppBundle:Position',
494494
'placeholder' => '',
495-
'choices' => $positions,
495+
'choices' => $positions,
496+
'choices_as_values' => true,
496497
));
497498
}
498499
);
@@ -553,9 +554,10 @@ The type would now look like::
553554
$positions = null === $sport ? array() : $sport->getAvailablePositions();
554555

555556
$form->add('position', 'entity', array(
556-
'class' => 'AppBundle:Position',
557+
'class' => 'AppBundle:Position',
557558
'placeholder' => '',
558-
'choices' => $positions,
559+
'choices' => $positions,
560+
'choices_as_values' => true,
559561
));
560562
};
561563

@@ -616,7 +618,7 @@ your application. Assume that you have a sport meetup creation controller::
616618
}
617619

618620
return $this->render(
619-
'@App/Meetup/create.html.twig',
621+
'meetup/create.html.twig',
620622
array('form' => $form->createView())
621623
);
622624
}
@@ -631,7 +633,7 @@ field according to the current selection in the ``sport`` field:
631633

632634
.. code-block:: html+twig
633635

634-
{# app/Resources/views/Meetup/create.html.twig #}
636+
{# app/Resources/views/meetup/create.html.twig #}
635637
{{ form_start(form) }}
636638
{{ form_row(form.sport) }} {# <select id="meetup_sport" ... #}
637639
{{ 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
@@ -184,7 +184,7 @@ In your controller, you'll now initialize a new instance of ``TaskType``::
184184
// ... maybe do some form processing, like saving the Task and Tag objects
185185
}
186186

187-
return $this->render('@App/Task/new.html.twig', array(
187+
return $this->render('task/new.html.twig', array(
188188
'form' => $form->createView(),
189189
));
190190
}
@@ -200,7 +200,7 @@ zero tags when first created).
200200

201201
.. code-block:: html+twig
202202

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

205205
{# ... #}
206206

0 commit comments

Comments
 (0)