Skip to content

Commit 21f5857

Browse files
committed
Merge branch '3.3' into 3.4
* 3.3: (31 commits) Revert "[symfony#7939] revert some changes (revert them for 3.2)" [symfony#7939] revert some changes (revert them for 3.2) Minor reword Update twig_reference.rst [symfony#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 Minor change Add reference to docs in frontend page Add typescript loader documentation Explained how to run tests in multiple kernel apps Fixed the explanation about PHPUnit event listeners in PHPUnitBridge Fix minor typo fixed typo in choice.rst regarding choice_loader File example update [symfony#8003] add XML and PHP config examples Reworded the help note adding note that CSRF protection has to be enabled in config ...
2 parents 84ddb53 + 1b47f37 commit 21f5857

25 files changed

+269
-86
lines changed

components/http_foundation.rst

+6-2
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

+25-4
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

+37
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.project_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

+8-3
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ service and use it directly::
114114

115115
public function indexAction($name)
116116
{
117-
$content = $this->twig->renderResponse(
117+
$content = $this->twig->render(
118118
'hello/index.html.twig',
119119
array('name' => $name)
120120
);

deployment.rst

+13-4
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

doctrine.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ a controller, this is pretty easy. Add the following method to the
506506
{
507507
// you can fetch the EntityManager via $this->getDoctrine()
508508
// or you can add an argument to your action: createAction(EntityManagerInterface $em)
509-
$em = $this->get('doctrine')->getManager();
509+
$em = $this->getDoctrine()->getManager();
510510

511511
$product = new Product();
512512
$product->setName('Keyboard');

doctrine/multiple_entity_managers.rst

+14-13
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,19 @@ When working with multiple entity managers to update your schema:
185185
If you *do* omit the entity manager's name when asking for it,
186186
the default entity manager (i.e. ``default``) is returned::
187187

188-
use Doctrine\ORM\EntityManagerInterface;
189-
use Doctrine\Common\Persistence\ManagerRegistry;
188+
// ...
190189

191190
class UserController extends Controller
192191
{
193-
public function indexAction(EntityManagerInterface $em, ManagerRegistry $doctrine)
192+
public function indexAction()
194193
{
195-
// All 4 return the "default" entity manager
196-
// $em from the EntityManagerInterface
197-
$em = $doctrine->getManager();
198-
$em = $doctrine->getManager('default');
194+
// All 3 return the "default" entity manager
195+
$em = $this->getDoctrine()->getManager();
196+
$em = $this->getDoctrine()->getManager('default');
199197
$em = $this->get('doctrine.orm.default_entity_manager');
200198

201199
// Both of these return the "customer" entity manager
202-
$customerEm = $doctrine->getManager('customer');
200+
$customerEm = $this->getDoctrine()->getManager('customer');
203201
$customerEm = $this->get('doctrine.orm.customer_entity_manager');
204202
}
205203
}
@@ -210,26 +208,29 @@ entity manager to persist and fetch its entities.
210208

211209
The same applies to repository calls::
212210

213-
use Doctrine\Common\Persistence\ManagerRegistry;
214211
use AcmeStoreBundle\Entity\Customer;
215212
use AcmeStoreBundle\Entity\Product;
213+
// ...
216214

217215
class UserController extends Controller
218216
{
219-
public function indexAction(ManagerRegistry $doctrine)
217+
public function indexAction()
220218
{
221219
// Retrieves a repository managed by the "default" em
222-
$products = $doctrine->getRepository(Product::class)
220+
$products = $this->getDoctrine()
221+
->getRepository(Product::class)
223222
->findAll()
224223
;
225224

226225
// Explicit way to deal with the "default" em
227-
$products = $doctrine->getRepository(Product::class, 'default')
226+
$products = $this->getDoctrine()
227+
->getRepository(Product::class, 'default')
228228
->findAll()
229229
;
230230

231231
// Retrieves a repository managed by the "customer" em
232-
$customers = $doctrine->getRepository(Customer::class, 'customer')
232+
$customers = $this->getDoctrine()
233+
->getRepository(Customer::class, 'customer')
233234
->findAll()
234235
;
235236
}

form/dynamic_form_modification.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ your application. Assume that you have a sport meetup creation controller::
528528
}
529529

530530
return $this->render(
531-
'@App/Meetup/create.html.twig',
531+
'meetup/create.html.twig',
532532
array('form' => $form->createView())
533533
);
534534
}
@@ -543,7 +543,7 @@ field according to the current selection in the ``sport`` field:
543543

544544
.. code-block:: html+twig
545545

546-
{# app/Resources/views/Meetup/create.html.twig #}
546+
{# app/Resources/views/meetup/create.html.twig #}
547547
{{ form_start(form) }}
548548
{{ form_row(form.sport) }} {# <select id="meetup_sport" ... #}
549549
{{ form_row(form.position) }} {# <select id="meetup_position" ... #}

form/form_collections.rst

+2-2
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

frontend.rst

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Adding more Features
4343
* :doc:`Enabling Vue.js (vue-loader) </frontend/encore/vuejs>`
4444
* :doc:`Configuring Babel </frontend/encore/babel>`
4545
* :doc:`Source maps </frontend/encore/sourcemaps>`
46+
* :doc:`Enabling TypeScript (ts-loader) </frontend/encore/typescript>`
4647

4748
Optimizing
4849
..........

frontend/encore/babel.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ Need to extend the Babel configuration further? The easiest way is via
1515
1616
Encore
1717
// ...
18-
19-
// modify the default Babel configuration
18+
19+
// first, install any presets you want to use (e.g. yarn add babel-preset-es2017)
20+
// then, modify the default Babel configuration
2021
.configureBabel(function(babelConfig) {
2122
babelConfig.presets.push('es2017');
2223
})

frontend/encore/typescript.rst

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Enabling TypeScript (ts-loader)
2+
===============================
3+
4+
Want to use `TypeScript`_? No problem! First, install the dependencies:
5+
6+
.. code-block:: terminal
7+
8+
$ yarn add --dev typescript ts-loader
9+
10+
Then, activate the ``ts-loader`` in ``webpack.config.js``:
11+
12+
.. code-block:: diff
13+
14+
// webpack.config.js
15+
// ...
16+
17+
Encore
18+
// ...
19+
.addEntry('main', './assets/main.ts')
20+
21+
.enableTypeScriptLoader()
22+
;
23+
24+
That's it! Any ``.ts`` files that you require will be processed correctly. You can
25+
also configure the `ts-loader options`_ via a callback:
26+
27+
.. code-block:: javascript
28+
29+
.enableTypeScriptLoader(function (typeScriptConfigOptions) {
30+
typeScriptConfigOptions.transpileOnly = true;
31+
typeScriptConfigOptions.configFileName = '/path/to/tsconfig.json';
32+
});
33+
34+
If React assets are enabled (``.enableReactPreset()``), any ``.tsx`` file will be
35+
processed as well by ``ts-loader``.
36+
37+
Loader usage can be checked better in its `README`_ documentation.
38+
39+
"Use webpack like normal, including ``webpack --watch`` and ``webpack-dev-server``,
40+
or through another build system using the Node.js API."
41+
42+
-- Running section of ts-loader documentation
43+
44+
.. _`TypeScript`: https://www.typescriptlang.org/
45+
.. _`ts-loader options`: https://github.com/TypeStrong/ts-loader#options
46+
.. _`README`: https://github.com/TypeStrong/ts-loader#typescript-loader-for-webpack

frontend/encore/versus-assetic.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Encore Versus Assetic?
33

44
Symfony originally shipped with support for :doc:`Assetic </assetic>`: a
55
pure PHP library capable of processing, combining and minifying CSS and JavaScript
6-
files. And while Encore is now the recommended way or processing your assets, Assetic
6+
files. And while Encore is now the recommended way of processing your assets, Assetic
77
still works well.
88

99
So what are the differences between Assetic and Encore?

profiler/data_collector.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ block and set the value of two variables called ``icon`` and ``text``:
161161

162162
.. code-block:: twig
163163
164-
{{ include('@App/data_collector/icon.svg') }}
164+
{{ include('data_collector/icon.svg') }}
165165
166166
You are encouraged to use the latter technique for your own toolbar panels.
167167

0 commit comments

Comments
 (0)