Skip to content

Commit a8a58f7

Browse files
committed
Merge branch '3.1'
2 parents 5ac8bb3 + c5754ef commit a8a58f7

File tree

5 files changed

+224
-20
lines changed

5 files changed

+224
-20
lines changed

changelog.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,66 @@ documentation.
1313
Do you also want to participate in the Symfony Documentation? Take a look
1414
at the ":doc:`/contributing/documentation/overview`" article.
1515

16+
June, 2016
17+
----------
18+
19+
New Documentation
20+
~~~~~~~~~~~~~~~~~
21+
22+
* `#6515 <https://github.com/symfony/symfony-docs/pull/6515>`_ Added the documentation for the Cache component (javiereguiluz)
23+
* `#6690 <https://github.com/symfony/symfony-docs/pull/6690>`_ Added an example for a different method of verbosity level usage. (smatyas)
24+
* `#6648 <https://github.com/symfony/symfony-docs/pull/6648>`_ Process: callbacks now allowed when output disabled (avindra)
25+
* `#6587 <https://github.com/symfony/symfony-docs/pull/6587>`_ Updating recommended email settings for monolog (jorgelbg)
26+
* `#6617 <https://github.com/symfony/symfony-docs/pull/6617>`_ [WSSE] - Using a PSR6 cache instead of file cache (Nyholm)
27+
* `#6438 <https://github.com/symfony/symfony-docs/pull/6438>`_ Added docs about ArgumentValueResolvers (iltar)
28+
29+
Fixed Documentation
30+
~~~~~~~~~~~~~~~~~~~
31+
32+
* `#6679 <https://github.com/symfony/symfony-docs/pull/6679>`_ Invalid PHP return statement (JohnnyEvo)
33+
* `#6675 <https://github.com/symfony/symfony-docs/pull/6675>`_ Update broken links to default VCL files (sgrodzicki)
34+
35+
Minor Documentation Changes
36+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
37+
38+
* `#6597 <https://github.com/symfony/symfony-docs/pull/6597>`_ [Validator] Add shorter examples using the default option (alexmart)
39+
* `#6696 <https://github.com/symfony/symfony-docs/pull/6696>`_ Typo fix (jevgenijusr)
40+
* `#6693 <https://github.com/symfony/symfony-docs/pull/6693>`_ Add missing parameter (rodnaph)
41+
* `#6614 <https://github.com/symfony/symfony-docs/pull/6614>`_ Updated the CS rule about return null; and return; (javiereguiluz)
42+
* `#6680 <https://github.com/symfony/symfony-docs/pull/6680>`_ Fix ldap security examples (jvasseur)
43+
* `#6692 <https://github.com/symfony/symfony-docs/pull/6692>`_ Update date.rst - Fixes typo (fdarre)
44+
* `#6689 <https://github.com/symfony/symfony-docs/pull/6689>`_ Hard values for the driver option (iltar)
45+
* `#6685 <https://github.com/symfony/symfony-docs/pull/6685>`_ NullOutput should be passed to $command->run() (Ma27)
46+
* `#6676 <https://github.com/symfony/symfony-docs/pull/6676>`_ Removed 'html' from the component description (naroga)
47+
* `#6674 <https://github.com/symfony/symfony-docs/pull/6674>`_ CheckStyle in Voters cookbook (JakeFr)
48+
* `#6672 <https://github.com/symfony/symfony-docs/pull/6672>`_ [Book][Testing] remove Symfony core testing note (xabbuh)
49+
* `#6670 <https://github.com/symfony/symfony-docs/pull/6670>`_ Fix typo 'even' >> 'event' in event_listener.rst (kuusas)
50+
* `#6667 <https://github.com/symfony/symfony-docs/pull/6667>`_ [Contributing][Code] fix list item terminators (xabbuh)
51+
* `#6616 <https://github.com/symfony/symfony-docs/pull/6616>`_ Better explain the mandatory/convention location of some elements (rcousens, javiereguiluz)
52+
* `#6628 <https://github.com/symfony/symfony-docs/pull/6628>`_ Fix for #6625 (kix)
53+
* `#6668 <https://github.com/symfony/symfony-docs/pull/6668>`_ [Contributing][Code] remove PHPUnit requirement (xabbuh)
54+
* `#6654 <https://github.com/symfony/symfony-docs/pull/6654>`_ Update upload_file.rst (liubinas)
55+
* `#6650 <https://github.com/symfony/symfony-docs/pull/6650>`_ fix dumper default representation (Jamal Youssefi)
56+
* `#6652 <https://github.com/symfony/symfony-docs/pull/6652>`_ ``Finder::path()`` method matching directories and files (soyuka)
57+
* `#6662 <https://github.com/symfony/symfony-docs/pull/6662>`_ preg_match throw an warning (nicolae-stelian)
58+
* `#6651 <https://github.com/symfony/symfony-docs/pull/6651>`_ [#6438] some tweaks to the argument value resolver (xabbuh)
59+
* `#6658 <https://github.com/symfony/symfony-docs/pull/6658>`_ [Process] tweak a sentence (xabbuh)
60+
* `#6599 <https://github.com/symfony/symfony-docs/pull/6599>`_ Fixed null description of query_builder option (HeahDude)
61+
* `#6638 <https://github.com/symfony/symfony-docs/pull/6638>`_ swap terminate and exception event descriptions (xabbuh)
62+
* `#6615 <https://github.com/symfony/symfony-docs/pull/6615>`_ Minor grammar fix (aalaap)
63+
* `#6637 <https://github.com/symfony/symfony-docs/pull/6637>`_ Update security.rst (norbert-n)
64+
* `#6644 <https://github.com/symfony/symfony-docs/pull/6644>`_ [Console] Fix wrong quotes in QuestionHelper::setInputStream() (chalasr)
65+
* `#6645 <https://github.com/symfony/symfony-docs/pull/6645>`_ Fix bootstrap class name help-block (foaly-nr1)
66+
* `#6642 <https://github.com/symfony/symfony-docs/pull/6642>`_ do not reference unused interface (xabbuh)
67+
* `#6641 <https://github.com/symfony/symfony-docs/pull/6641>`_ [Book][Form] fix reference to renamed document (xabbuh)
68+
* `#6579 <https://github.com/symfony/symfony-docs/pull/6579>`_ Added callable validation_groups example (gnat42)
69+
* `#6626 <https://github.com/symfony/symfony-docs/pull/6626>`_ reflect the EOM of Symfony 2.3 (xabbuh)
70+
* `#6631 <https://github.com/symfony/symfony-docs/pull/6631>`_ Fix console.exception and console.terminate order (Julien Falque)
71+
* `#6629 <https://github.com/symfony/symfony-docs/pull/6629>`_ Update options_resolver.rst (atailouloute)
72+
* `#6627 <https://github.com/symfony/symfony-docs/pull/6627>`_ Fixed a typo in cookbook/security/entity_provider (michaeldegroot)
73+
* `#6618 <https://github.com/symfony/symfony-docs/pull/6618>`_ Added a note about coding standards and method arguments (javiereguiluz)
74+
75+
1676
May, 2016
1777
---------
1878

components/process.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ the contents of the output and
5050
:method:`Symfony\\Component\\Process\\Process::clearErrorOutput` clears
5151
the contents of the error output.
5252

53+
.. versionadded:: 3.1
54+
Support for streaming the output of a process was introduced in
55+
Symfony 3.1.
56+
57+
You can also use the :class:`Symfony\\Component\\Process\\Process` class with the
58+
foreach construct to get the output while it is generated. By default, the loop waits
59+
for new output before going to the next iteration::
60+
61+
$process = new Process('ls -lsa');
62+
$process->start();
63+
64+
foreach ($process as $type => $data) {
65+
if ($process::OUT === $type) {
66+
echo "\nRead from stdout: ".$data;
67+
} else { // $process::ERR === $type
68+
echo "\nRead from stderr: ".$data;
69+
}
70+
}
71+
5372
The ``mustRun()`` method is identical to ``run()``, except that it will throw
5473
a :class:`Symfony\\Component\\Process\\Exception\\ProcessFailedException`
5574
if the process couldn't be executed successfully (i.e. the process exited
@@ -128,6 +147,50 @@ are done doing other stuff::
128147
which means that your code will halt at this line until the external
129148
process is completed.
130149

150+
Streaming to the Standard Input of a Process
151+
--------------------------------------------
152+
153+
.. versionadded:: 3.1
154+
Support for streaming the input of a process was introduced in
155+
Symfony 3.1.
156+
157+
Before a process is started, you can specify its standard input using either the
158+
:method:`Symfony\\Component\\Process\\Process::setInput` method or the 4th argument
159+
of the constructor. The provided input can be a string, a stream resource or a
160+
Traversable object::
161+
162+
$process = new Process('cat');
163+
$process->setInput('foobar');
164+
$process->run();
165+
166+
When this input is fully written to the subprocess standard input, the corresponding
167+
pipe is closed.
168+
169+
In order to write to a subprocess standard input while it is running, the component
170+
provides the :class:`Symfony\\Component\\Process\\InputStream` class::
171+
172+
$input = new InputStream();
173+
$input->write('foo');
174+
175+
$process = new Process('cat');
176+
$process->setInput($input);
177+
$process->start();
178+
179+
// ... read process output or do other things
180+
181+
$input->write('bar');
182+
$input->close();
183+
184+
$process->wait();
185+
186+
// will echo: foobar
187+
echo $process->getOutput();
188+
189+
The :method:`Symfony\\Component\\Process\\InputStream::write` method accepts scalars,
190+
stream resources or Traversable objects as argument. As shown in the above example,
191+
you need to explicitly call the :method:`Symfony\\Component\\Process\\InputStream::close`
192+
method when you are done writing to the standard input of the subprocess.
193+
131194
Stopping a Process
132195
------------------
133196

cookbook/security/impersonating_user.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,18 @@ How to Impersonate a User
66

77
Sometimes, it's useful to be able to switch from one user to another without
88
having to log out and log in again (for instance when you are debugging or trying
9-
to understand a bug a user sees that you can't reproduce). This can be easily
10-
done by activating the ``switch_user`` firewall listener:
9+
to understand a bug a user sees that you can't reproduce).
10+
11+
.. caution::
12+
13+
User impersonation is not compatible with
14+
:doc:`pre authenticated firewalls </cookbook/security/pre_authenticated>`. The
15+
reason is that impersonation requires the authentication state to be maintained
16+
server-side, but pre-authenticated information (``SSL_CLIENT_S_DN_Email``,
17+
``REMOTE_USER`` or other) is sent in each request.
18+
19+
Impersonating the user can be easily done by activating the ``switch_user``
20+
firewall listener:
1121

1222
.. configuration-block::
1323

cookbook/security/pre_authenticated.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ box, Symfony supports most authentication mechanisms.
1111
These requests are called *pre authenticated* requests because the user is already
1212
authenticated when reaching your application.
1313

14+
.. caution::
15+
16+
:doc:`User impersonation </cookbook/security/impersonating_user>` is not
17+
compatible with pre-authenticated firewalls. The reason is that
18+
impersonation requires the authentication state to be maintained server-side,
19+
but pre-authenticated information (``SSL_CLIENT_S_DN_Email``, ``REMOTE_USER``
20+
or other) is sent in each request.
21+
1422
X.509 Client Certificate Authentication
1523
---------------------------------------
1624

@@ -149,9 +157,3 @@ key in the ``remote_user`` firewall configuration.
149157
See :ref:`the previous note <cookbook-security-pre-authenticated-user-provider-note>`
150158
for more information.
151159

152-
.. caution::
153-
154-
:doc:`User impersonation </cookbook/security/impersonating_user>` is not
155-
compatible with ``REMOTE_USER`` based authentication. The reason is that
156-
impersonation requires the authentication state to be maintained server-side
157-
but ``REMOTE_USER`` information is sent by the browser in each request.

cookbook/session/proxy_examples.rst

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,92 @@
44
Session Proxy Examples
55
======================
66

7-
The session proxy mechanism has a variety of uses and this example demonstrates
8-
two common uses. Rather than injecting the session handler as normal, a handler
9-
is injected into the proxy and registered with the session storage driver::
7+
The session proxy mechanism has a variety of uses and this article demonstrates
8+
two common uses. Rather than using the regular session handler, you can create
9+
a custom save handler just by defining a class that extends the
10+
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy`
11+
class.
1012

11-
use Symfony\Component\HttpFoundation\Session\Session;
12-
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
13-
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
13+
Then, define a new service related to the custom session handler:
1414

15-
$proxy = new YourProxy(new PdoSessionHandler());
16-
$session = new Session(new NativeSessionStorage(array(), $proxy));
15+
.. configuration-block::
1716

18-
Below, you'll learn two real examples that can be used for ``YourProxy``:
19-
encryption of session data and readonly guest sessions.
17+
.. code-block:: yaml
18+
19+
# app/config/services.yml
20+
services:
21+
app.session_handler:
22+
class: AppBundle\Session\CustomSessionHandler
23+
24+
.. code-block:: xml
25+
26+
<!-- app/config/services.xml -->
27+
<?xml version="1.0" encoding="UTF-8" ?>
28+
<container xmlns="http://symfony.com/schema/dic/services"
29+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
30+
xsi:schemaLocation="http://symfony.com/schema/dic/services
31+
http://symfony.com/schema/dic/services/services-1.0.xsd">
32+
33+
<services>
34+
<service id="app.session_handler" class="AppBundle\Session\CustomSessionHandler" />
35+
</services>
36+
</container>
37+
38+
.. code-block:: php
39+
40+
// app/config/config.php
41+
$container->register('app.session_handler', 'AppBundle\Session\CustomSessionHandler');
42+
43+
Finally, use the ``framework.session.handler_id`` configuration option to tell
44+
Symfony to use your own session handler instead of the default one:
45+
46+
.. configuration-block::
47+
48+
.. code-block:: yaml
49+
50+
# app/config/config.yml
51+
framework:
52+
session:
53+
# ...
54+
handler_id: app.session_handler
55+
56+
.. code-block:: xml
57+
58+
<!-- app/config/config.xml -->
59+
<?xml version="1.0" encoding="UTF-8" ?>
60+
<container xmlns="http://symfony.com/schema/dic/services"
61+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
62+
xsi:schemaLocation="http://symfony.com/schema/dic/services
63+
http://symfony.com/schema/dic/services/services-1.0.xsd">
64+
<framework:config>
65+
<framework:session handler-id="app.session_handler" ... />
66+
</framework:config>
67+
</container>
68+
69+
.. code-block:: php
70+
71+
// app/config/config.php
72+
$container->loadFromExtension('framework', array(
73+
// ...
74+
'session' => array(
75+
// ...
76+
'handler_id' => 'app.session_handler',
77+
),
78+
));
79+
80+
Keep reading the next sections to learn how to use the session handlers in practice
81+
to solve two common use cases: encrypt session information and define readonly
82+
guest sessions.
2083

2184
Encryption of Session Data
2285
--------------------------
2386

2487
If you wanted to encrypt the session data, you could use the proxy to encrypt
2588
and decrypt the session as required::
2689

90+
// src/AppBundle/Session/EncryptedSessionProxy.php
91+
namespace AppBundle\Session;
92+
2793
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
2894

2995
class EncryptedSessionProxy extends SessionHandlerProxy
@@ -59,10 +125,13 @@ There are some applications where a session is required for guest users, but
59125
where there is no particular need to persist the session. In this case you
60126
can intercept the session before it is written::
61127

62-
use Foo\User;
128+
// src/AppBundle/Session/ReadOnlySessionProxy.php
129+
namespace AppBundle\Session;
130+
131+
use AppBundle\Entity\User;
63132
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
64133

65-
class ReadOnlyGuestSessionProxy extends SessionHandlerProxy
134+
class ReadOnlySessionProxy extends SessionHandlerProxy
66135
{
67136
private $user;
68137

0 commit comments

Comments
 (0)