Skip to content

Commit e93c251

Browse files
committed
Merge branch '2.3' into 2.6
2 parents e5d68b5 + 3bb1a25 commit e93c251

File tree

6 files changed

+124
-23
lines changed

6 files changed

+124
-23
lines changed

components/console/introduction.rst

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ output. For example::
140140
// white text on a red background
141141
$output->writeln('<error>foo</error>');
142142

143+
The closing tag can be replaced by ``</>``, which revokes all formatting options
144+
established by the last opened tag.
145+
143146
It is possible to define your own styles using the class
144147
:class:`Symfony\\Component\\Console\\Formatter\\OutputFormatterStyle`::
145148

@@ -148,23 +151,27 @@ It is possible to define your own styles using the class
148151
// ...
149152
$style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink'));
150153
$output->getFormatter()->setStyle('fire', $style);
151-
$output->writeln('<fire>foo</fire>');
154+
$output->writeln('<fire>foo</>');
152155

153156
Available foreground and background colors are: ``black``, ``red``, ``green``,
154157
``yellow``, ``blue``, ``magenta``, ``cyan`` and ``white``.
155158

156-
And available options are: ``bold``, ``underscore``, ``blink``, ``reverse`` and ``conceal``.
159+
And available options are: ``bold``, ``underscore``, ``blink``, ``reverse``
160+
(enables the "reverse video" mode where the background and foreground colors
161+
are swapped) and ``conceal`` (sets the foreground color to transparent, making
162+
the typed text invisible - although it can be selected and copied; this option is
163+
commonly used when asking the user to type sensitive information).
157164

158165
You can also set these colors and options inside the tagname::
159166

160167
// green text
161-
$output->writeln('<fg=green>foo</fg=green>');
168+
$output->writeln('<fg=green>foo</>');
162169

163170
// black text on a cyan background
164-
$output->writeln('<fg=black;bg=cyan>foo</fg=black;bg=cyan>');
171+
$output->writeln('<fg=black;bg=cyan>foo</>');
165172

166173
// bold text on a yellow background
167-
$output->writeln('<bg=yellow;options=bold>foo</bg=yellow;options=bold>');
174+
$output->writeln('<bg=yellow;options=bold>foo</>');
168175

169176
.. _verbosity-levels:
170177

@@ -296,15 +303,15 @@ You can access the ``names`` argument as an array::
296303
$text .= ' '.implode(', ', $names);
297304
}
298305

299-
There are 3 argument variants you can use:
306+
There are three argument variants you can use:
300307

301-
=========================== ===============================================================================================================
308+
=========================== ===========================================================================================================
302309
Mode Value
303-
=========================== ===============================================================================================================
304-
InputArgument::REQUIRED The argument is required
305-
InputArgument::OPTIONAL The argument is optional and therefore can be omitted
306-
InputArgument::IS_ARRAY The argument can contain an indefinite number of arguments and must be used at the end of the argument list
307-
=========================== ===============================================================================================================
310+
=========================== ===========================================================================================================
311+
``InputArgument::REQUIRED`` The argument is required
312+
``InputArgument::OPTIONAL`` The argument is optional and therefore can be omitted
313+
``InputArgument::IS_ARRAY`` The argument can contain an indefinite number of arguments and must be used at the end of the argument list
314+
=========================== ===========================================================================================================
308315

309316
You can combine ``IS_ARRAY`` with ``REQUIRED`` and ``OPTIONAL`` like this::
310317

@@ -377,14 +384,14 @@ will work:
377384
378385
There are 4 option variants you can use:
379386

380-
=========================== =====================================================================================
381-
Option Value
382-
=========================== =====================================================================================
383-
InputOption::VALUE_IS_ARRAY This option accepts multiple values (e.g. ``--dir=/foo --dir=/bar``)
384-
InputOption::VALUE_NONE Do not accept input for this option (e.g. ``--yell``)
385-
InputOption::VALUE_REQUIRED This value is required (e.g. ``--iterations=5``), the option itself is still optional
386-
InputOption::VALUE_OPTIONAL This option may or may not have a value (e.g. ``--yell`` or ``--yell=loud``)
387-
=========================== =====================================================================================
387+
=============================== =====================================================================================
388+
Option Value
389+
=============================== =====================================================================================
390+
``InputOption::VALUE_IS_ARRAY`` This option accepts multiple values (e.g. ``--dir=/foo --dir=/bar``)
391+
``InputOption::VALUE_NONE`` Do not accept input for this option (e.g. ``--yell``)
392+
``InputOption::VALUE_REQUIRED`` This value is required (e.g. ``--iterations=5``), the option itself is still optional
393+
``InputOption::VALUE_OPTIONAL`` This option may or may not have a value (e.g. ``--yell`` or ``--yell=loud``)
394+
=============================== =====================================================================================
388395

389396
You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or ``VALUE_OPTIONAL`` like this:
390397

cookbook/configuration/web_server_configuration.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,13 @@ The **minimum configuration** to get your application running under Nginx is:
269269
fastcgi_split_path_info ^(.+\.php)(/.*)$;
270270
include fastcgi_params;
271271
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
272-
fastcgi_param HTTPS off;
273272
}
274273
# PROD
275274
location ~ ^/app\.php(/|$) {
276275
fastcgi_pass unix:/var/run/php5-fpm.sock;
277276
fastcgi_split_path_info ^(.+\.php)(/.*)$;
278277
include fastcgi_params;
279278
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
280-
fastcgi_param HTTPS off;
281279
# Prevents URIs that include the front controller. This will 404:
282280
# http://domain.tld/app.php/some-path
283281
# Remove the internal directive to allow URIs like this

cookbook/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The Cookbook
2828
serializer
2929
service_container/index
3030
session/index
31+
psr7
3132
symfony1
3233
templating/index
3334
testing/index

cookbook/map.rst.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@
205205
* (configuration) :doc:`/cookbook/configuration/mongodb_session_storage`
206206
* :doc:`/cookbook/session/avoid_session_start`
207207

208+
* **PSR-7**
209+
210+
* :doc:`/cookbook/psr7`
211+
208212
* **symfony1**
209213

210214
* :doc:`/cookbook/symfony1`

cookbook/psr7.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
.. index::
2+
single: PSR-7
3+
4+
The PSR-7 Bridge
5+
================
6+
7+
The PSR-7 bridge converts :doc:`HttpFoundation </components/http_foundation/index>`
8+
objects from and to objects implementing HTTP message interfaces defined
9+
by the `PSR-7`_.
10+
11+
Installation
12+
------------
13+
14+
You can install the component in 2 different ways:
15+
16+
* :doc:`Install it via Composer </components/using_components>` (``symfony/psr-http-message-bridge`` on `Packagist`_);
17+
* Use the official Git repository (https://github.com/symfony/psr-http-message-bridge).
18+
19+
The bridge also needs a PSR-7 implementation to allow converting HttpFoundation
20+
objects to PSR-7 objects. It provides native support for `Zend Diactoros`_.
21+
Use Composer (``zendframework/zend-diactoros`` on `Packagist`_) or refer to
22+
the project documentation to install it.
23+
24+
Usage
25+
-----
26+
27+
Converting from HttpFoundation Objects to PSR-7
28+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29+
30+
The bridge provides an interface of a factory called
31+
:class:`Symfony\\Bridge\\PsrHttpMessage\\HttpMessageFactoryInterface`
32+
that builds objects implementing PSR-7 interfaces from HttpFoundation objects.
33+
It also provide a default implementation using Zend Diactoros internally.
34+
35+
The following code snippet explain how to convert a :class:`Symfony\\Component\\HttpFoundation\\Request`
36+
to a Zend Diactoros :class:`Zend\\Diactoros\\ServerRequest` implementing the
37+
:class:`Psr\\Http\\Message\\ServerRequestInterface` interface::
38+
39+
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
40+
use Symfony\Component\HttpFoundation\Request;
41+
42+
$symfonyRequest = new Request(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'dunglas.fr'), 'Content');
43+
// The HTTP_HOST server key must be set to avoid an unexpected error
44+
45+
$psr7Factory = new DiactorosFactory();
46+
$psrRequest = $psr7Factory->createRequest($symfonyRequest);
47+
48+
And now from a :class:`Symfony\\Component\\HttpFoundation\\Response` to a Zend
49+
Diactoros :class:`Zend\\Diactoros\\Response` implementing the :class:`Psr\\Http\\Message\\ResponseInterface`
50+
interface::
51+
52+
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
53+
use Symfony\Component\HttpFoundation\Response;
54+
55+
$symfonyResponse = new Response('Content');
56+
57+
$psr7Factory = new DiactorosFactory();
58+
$psrResponse = $psr7Factory->createResponse($symfonyResponse);
59+
60+
Converting Objects implementing PSR-7 Interfaces to HttpFoundation
61+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62+
63+
On the other hand, the bridge provide a factory interface called
64+
:class:`Symfony\\Bridge\\PsrHttpMessage\\HttpFoundationFactoryInterface`
65+
that builds HttpFoundation objects from objects implementing PSR-7 interfaces.
66+
67+
The next snippet explain how to convert an object implementing the :class:`Psr\\Http\\Message\\ServerRequestInterface`
68+
interface to a :class:`Symfony\\Component\\HttpFoundation\\Request` instance::
69+
70+
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
71+
72+
// $psrRequest is an instance of Psr\Http\Message\ServerRequestInterface
73+
74+
$httpFoundationFactory = new HttpFoundationFactory();
75+
$symfonyRequest = $httpFoundationFactory->createRequest($psrRequest);
76+
77+
From an object implementing the :class:`Psr\\Http\\Message\\ResponseInterface`
78+
to a :class:`Symfony\\Component\\HttpFoundation\\Response` instance::
79+
80+
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
81+
82+
// $psrResponse is an instance of Psr\Http\Message\ResponseInterface
83+
84+
$httpFoundationFactory = new HttpFoundationFactory();
85+
$symfonyResponse = $httpFoundationFactory->createResponse($psrResponse);
86+
87+
.. _`PSR-7`: http://www.php-fig.org/psr/psr-7/
88+
.. _Packagist: https://packagist.org/packages/symfony/psr-http-message-bridge
89+
.. _`Zend Diactoros`: https://github.com/zendframework/zend-diactoros

create_framework/front-controller.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,13 @@ web root directory:
146146
147147
example.com
148148
├── composer.json
149-
│ src
149+
├── composer.lock
150+
├── src
150151
│ └── pages
151152
│ ├── hello.php
152153
│ └── bye.php
153154
├── vendor
155+
│ └── autoload.php
154156
└── web
155157
└── front.php
156158

0 commit comments

Comments
 (0)