Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4166339

Browse files
committed
Merge branch '2.3' into 2.6
* 2.3: [#5033] Tweaking variable name to "match" the service id [#5017] Minor language tweaks use definition list instead of table adding table for controller as a service Suggested ConEmu in addition to ANSICON to solve the Windows coloring limitation Minor rewording Reworded the note about Windows console and output coloring Update routing.rst Minor rewording add a note about apc for php recent versions Removed a wrong link to a included file Rewording Minor rewording Fixed an internal link Added a note about data transformers not being applied with inherit_data option set Added a commented config useful when you use symlinks Minor rewording Added a note about the class option of the services defined via factories Added a note about the server_version DBAL option Conflicts: components/dependency_injection/factories.rst
2 parents d6c0cb7 + 42c9f53 commit 4166339

File tree

10 files changed

+168
-15
lines changed

10 files changed

+168
-15
lines changed

book/performance.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ Use a Byte Code Cache (e.g. APC)
1818
One of the best (and easiest) things that you should do to improve your performance
1919
is to use a "byte code cache". The idea of a byte code cache is to remove
2020
the need to constantly recompile the PHP source code. There are a number of
21-
`byte code caches`_ available, some of which are open source. The most widely
22-
used byte code cache is probably `APC`_
21+
`byte code caches`_ available, some of which are open source. As of PHP 5.5,
22+
PHP comes with `OPcache`_ built-in. For older versions, the most widely used
23+
byte code cache is probably `APC`_
2324

2425
Using a byte code cache really has no downside, and Symfony has been architected
2526
to perform really well in this type of environment.
@@ -139,6 +140,7 @@ feature is disabled in the byte code cache (e.g. ``apc.stat=0`` in APC), there
139140
is no longer a reason to use a bootstrap file.
140141

141142
.. _`byte code caches`: http://en.wikipedia.org/wiki/List_of_PHP_accelerators
143+
.. _`OPcache`: http://php.net/manual/en/book.opcache.php
142144
.. _`APC`: http://php.net/manual/en/book.apc.php
143145
.. _`autoload.php`: https://github.com/symfony/symfony-standard/blob/master/app/autoload.php
144146
.. _`bootstrap file`: https://github.com/sensio/SensioDistributionBundle/blob/master/Composer/ScriptHandler.php

book/routing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The route is simple:
4545
class BlogController extends Controller
4646
{
4747
/**
48-
* @Route("/blog/{slug}")
48+
* @Route("/blog/{slug}", name="blog_show")
4949
*/
5050
public function showAction($slug)
5151
{

components/console/introduction.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ You can install the component in 2 different ways:
2020
* :doc:`Install it via Composer </components/using_components>` (``symfony/console`` on `Packagist`_);
2121
* Use the official Git repository (https://github.com/symfony/Console).
2222

23-
.. note::
24-
25-
Windows does not support ANSI colors by default so the Console component detects and
26-
disables colors where Windows does not have support. However, if Windows is not
27-
configured with an ANSI driver and your console commands invoke other scripts which
28-
emit ANSI color sequences, they will be shown as raw escape characters.
29-
30-
To enable ANSI color support for Windows, please install `ANSICON`_.
31-
3223
Creating a basic Command
3324
------------------------
3425

@@ -124,6 +115,14 @@ This prints::
124115
Coloring the Output
125116
~~~~~~~~~~~~~~~~~~~
126117

118+
.. note::
119+
120+
By default, the Windows command console doesn't support output coloring. The
121+
Console component disables output coloring for Windows systems, but if your
122+
commands invoke other scripts which emit color sequences, they will be
123+
wrongly displayed as raw escape characters. Install the `ConEmu`_ or `ANSICON`_
124+
free applications to add coloring support to your Windows command console.
125+
127126
Whenever you output text, you can surround the text with tags to color its
128127
output. For example::
129128

@@ -535,4 +534,5 @@ Learn More!
535534
* :doc:`/components/console/console_arguments`
536535

537536
.. _Packagist: https://packagist.org/packages/symfony/console
537+
.. _ConEmu: https://code.google.com/p/conemu-maximus5/
538538
.. _ANSICON: https://github.com/adoxa/ansicon/releases

components/dependency_injection/factories.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ configure the service container to use the
6969
7070
$container->setDefinition('newsletter_manager', $definition);
7171
72+
.. note::
73+
74+
When using a factory to create services, the value chosen for the ``class``
75+
option has no effect on the resulting service. The actual class name only
76+
depends on the object that is returned by the factory. However, the configured
77+
class name may be used by compiler passes and therefore should be set to a
78+
sensible value.
79+
7280
Now, the method will be called statically. If the factory class itself should
7381
be instantiated and the resulting object's method called, configure the factory
7482
itself as a service. In this case, the method (e.g. get) should be changed to

cookbook/configuration/web_server_configuration.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ are:
4848
Allow from All
4949
</Directory>
5050
51+
# uncomment the following lines if you install assets as symlinks
52+
# or run into problems when compiling LESS/Sass/CoffeScript assets
53+
# <Directory /var/www/project>
54+
# Option FollowSymlinks
55+
# </Directory>
56+
5157
ErrorLog /var/log/apache2/project_error.log
5258
CustomLog /var/log/apache2/project_access.log combined
5359
</VirtualHost>
@@ -151,6 +157,12 @@ directive to pass requests for PHP files to PHP FPM:
151157
Require all granted
152158
</Directory>
153159
160+
# uncomment the following lines if you install assets as symlinks
161+
# or run into problems when compiling LESS/Sass/CoffeScript assets
162+
# <Directory /var/www/project>
163+
# Option FollowSymlinks
164+
# </Directory>
165+
154166
ErrorLog /var/log/apache2/project_error.log
155167
CustomLog /var/log/apache2/project_access.log combined
156168
</VirtualHost>
@@ -181,6 +193,12 @@ should look something like this:
181193
Allow from all
182194
</Directory>
183195
196+
# uncomment the following lines if you install assets as symlinks
197+
# or run into problems when compiling LESS/Sass/CoffeScript assets
198+
# <Directory /var/www/project>
199+
# Option FollowSymlinks
200+
# </Directory>
201+
184202
ErrorLog /var/log/apache2/project_error.log
185203
CustomLog /var/log/apache2/project_access.log combined
186204
</VirtualHost>

cookbook/controller/service.rst

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ this works fine, controllers can also be specified as services.
2121
looking at the constructor arguments, it's easy to see what types of things
2222
this controller may or may not do. And because each dependency needs
2323
to be injected manually, it's more obvious (i.e. if you have many constructor
24-
arguments) when your controller has become too big, and may need to be
25-
split into multiple controllers.
24+
arguments) when your controller is becoming too big. The recommendation from
25+
the :doc:`best practices </best_practices/controllers>` is also valid for
26+
controllers defined as services: Avoid putting your business logic into the
27+
controllers. Instead, inject services that do the bulk of the work.
2628

2729
So, even if you don't specify your controllers as services, you'll likely
2830
see this done in some open-source Symfony bundles. It's also important
@@ -236,6 +238,91 @@ inject *only* the exact service(s) that you need directly into the controller.
236238
are valid, exactly how you want to organize your reusable code is up to
237239
you.
238240

241+
Base Controller Methods and Their Service Replacements
242+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
243+
244+
This list explains how to replace the convenience methods of the base
245+
controller:
246+
247+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::createForm` (service: ``form.factory``)
248+
.. code-block:: php
249+
250+
$formFactory->create($type, $data, $options);
251+
252+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::createFormBuilder` (service: ``form.factory``)
253+
.. code-block:: php
254+
255+
$formFactory->createBuilder('form', $data, $options);
256+
257+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::createNotFoundException`
258+
.. code-block:: php
259+
260+
new NotFoundHttpException($message, $previous);
261+
262+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::forward` (service: ``http_kernel``)
263+
.. code-block:: php
264+
265+
$httpKernel->forward($controller, $path, $query);
266+
267+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::generateUrl` (service: ``router``)
268+
.. code-block:: php
269+
270+
$router->generate($route, $params, $absolute);
271+
272+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getDoctrine` (service: ``doctrine``)
273+
274+
*Simply inject doctrine instead of fetching it from the container*
275+
276+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getUser` (service: ``security.context``)
277+
.. code-block:: php
278+
279+
$user = null;
280+
$token = $securityContext->getToken();
281+
if (null !== $token && is_object($token->getUser())) {
282+
$user = $token->getUser();
283+
}
284+
285+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::isGranted` (service: ``security.context``)
286+
.. code-block:: php
287+
288+
$securityContext->isGranted($attributes, $object);
289+
290+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::redirect`
291+
.. code-block:: php
292+
293+
use Symfony\Component\HttpFoundation\RedirectResponse;
294+
295+
return new RedirectResponse($url, $status);
296+
297+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::render` (service: ``templating``)
298+
.. code-block:: php
299+
300+
$templating->renderResponse($view, $parameters, $response);
301+
302+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::renderView` (service: ``templating``)
303+
.. code-block:: php
304+
305+
$templating->render($view, $parameters);
306+
307+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::stream` (service: ``templating``)
308+
.. code-block:: php
309+
310+
use Symfony\Component\HttpFoundation\StreamedResponse;
311+
312+
$templating = $this->templating;
313+
$callback = function () use ($templating, $view, $parameters) {
314+
$templating->stream($view, $parameters);
315+
}
316+
317+
return new StreamedResponse($callback);
318+
319+
.. tip::
320+
321+
``getRequest`` has been deprecated. Instead, have an argument to your
322+
controller action method called ``Request $request``. The order of the
323+
parameters is not important, but the typehint must be provided.
324+
325+
239326
.. _`Controller class source code`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
240327
.. _`base Controller class`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
241328
.. _`FrameworkExtraBundle documentation`: http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html

cookbook/doctrine/dbal.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ To get started, configure the database connection parameters:
3535
user: root
3636
password: null
3737
charset: UTF8
38+
server_version: 5.6
3839
3940
.. code-block:: xml
4041
@@ -45,6 +46,8 @@ To get started, configure the database connection parameters:
4546
dbname="Symfony"
4647
user="root"
4748
password="null"
49+
charset="UTF8"
50+
server-version="5.6"
4851
driver="pdo_mysql"
4952
/>
5053
</doctrine:config>
@@ -58,6 +61,8 @@ To get started, configure the database connection parameters:
5861
'dbname' => 'Symfony',
5962
'user' => 'root',
6063
'password' => null,
64+
'charset' => 'UTF8',
65+
'server_version' => '5.6',
6166
),
6267
));
6368

cookbook/form/data_transformers.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ You could try to do this in your controller, but it's not the best solution.
1717
It would be better if this issue were automatically converted to an Issue object.
1818
This is where Data Transformers come into play.
1919

20+
.. caution::
21+
22+
When a form field has the ``inherit_data`` option set, Data Transformers
23+
won't be applied to that field.
24+
2025
Creating the Transformer
2126
------------------------
2227

reference/configuration/doctrine.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Full Default Configuration
6060
driver: pdo_mysql
6161
platform_service: ~
6262
63+
# the version of your database engine
64+
server_version: ~
65+
6366
# when true, queries are logged to a "doctrine" monolog channel
6467
logging: "%kernel.debug%"
6568
profiling: "%kernel.debug%"
@@ -102,6 +105,9 @@ Full Default Configuration
102105
# True to use a pooled server with the oci8 driver
103106
pooled: ~
104107
108+
# the version of your database engine
109+
server_version: ~
110+
105111
# Configuring MultipleActiveResultSets for the pdo_sqlsrv driver
106112
MultipleActiveResultSets: ~
107113
@@ -202,6 +208,7 @@ Full Default Configuration
202208
charset="UTF8"
203209
logging="%kernel.debug%"
204210
platform-service="MyOwnDatabasePlatformService"
211+
server-version="5.6"
205212
>
206213
<doctrine:option key="foo">bar</doctrine:option>
207214
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
@@ -393,6 +400,7 @@ The following block shows all possible configuration keys:
393400
charset: UTF8
394401
logging: "%kernel.debug%"
395402
platform_service: MyOwnDatabasePlatformService
403+
server_version: 5.6
396404
mapping_types:
397405
enum: string
398406
types:
@@ -428,7 +436,8 @@ The following block shows all possible configuration keys:
428436
wrapper-class="MyDoctrineDbalConnectionWrapper"
429437
charset="UTF8"
430438
logging="%kernel.debug%"
431-
platform-service="MyOwnDatabasePlatformService">
439+
platform-service="MyOwnDatabasePlatformService"
440+
server-version="5.6">
432441
433442
<doctrine:option key="foo">bar</doctrine:option>
434443
<doctrine:mapping-type name="enum">string</doctrine:mapping-type>
@@ -437,6 +446,17 @@ The following block shows all possible configuration keys:
437446
</doctrine:config>
438447
</container>
439448
449+
.. note::
450+
451+
The ``server_version`` option was added in Doctrine DBAL 2.5, which is used
452+
by DoctrineBundle 1.3. The value of this option should match your database
453+
server version (use ``postgres -V`` or ``psql -V`` command to find
454+
your PostgreSQL version and ``mysql -V`` to get your MySQL version).
455+
456+
If you don't define this option and you haven't created your database yet,
457+
you may get ``PDOException`` errors because Doctrine will try to guess the
458+
database server version automatically and none is available.
459+
440460
If you want to configure multiple connections in YAML, put them under the
441461
``connections`` key and give them a unique name:
442462

@@ -451,11 +471,13 @@ If you want to configure multiple connections in YAML, put them under the
451471
user: root
452472
password: null
453473
host: localhost
474+
server_version: 5.6
454475
customer:
455476
dbname: customer
456477
user: root
457478
password: null
458479
host: localhost
480+
server_version: 5.7
459481
460482
The ``database_connection`` service always refers to the *default* connection,
461483
which is the first one defined or the one configured via the

reference/forms/types/options/inherit_data.rst.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ inherit_data
1010
This option determines if the form will inherit data from its parent form.
1111
This can be useful if you have a set of fields that are duplicated across
1212
multiple forms. See :doc:`/cookbook/form/inherit_data_option`.
13+
14+
.. caution::
15+
16+
When a field has the ``inherit_data`` option set, it uses the data of the
17+
parent form as is. This means that :doc:`Data Transformers </cookbook/form/data_transformers>`
18+
won't be applied to that field.

0 commit comments

Comments
 (0)