10000 --- · githubfromgui/symfony-docs@33d7424 · GitHub
[go: up one dir, main page]

Skip to content

Commit 33d7424

Browse files
committed
---
yaml --- r: 73438 b: refs/heads/5.x c: 525078f h: refs/heads/5.x
1 parent 5438454 commit 33d7424

File tree

148 files changed

+7621
-1383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+7621
-1383
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ refs/heads/3.3: 93587037fef6a2f40e0cbdea41754e1e76255fe6
9292
refs/heads/weaverryan-patch-1: a52aee3dceba3357dd59558677811a2ff86d1357
9393
refs/heads/4.0: e887a8b5e5d102235545837506f1d4e883f051a5
9494
refs/heads/4.1: 67f3845bc17a81379c609af1944099706e5b429e
95-
refs/heads/5.x: 7bacf005962801090584ac93dc160a535c6abe9a
95+
refs/heads/5.x: 525078fe7ff981429c76ed4e33c788c4c8924caa

trunk/_build/redirection_map

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@
421421
/configuration/configuration_organization /configuration
422422
/configuration/environments /configuration
423423
/configuration/configuration_organization /configuration
424+
/email/dev_environment /mailer
425+
/email/spool /mailer
426+
/email/testing /mailer
424427
/contributing/community/other /contributing/community
425428
/profiler/storage /profiler
426429
/setup/composer /setup
Loading

trunk/best_practices/security.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ remain resistant to brute-force search attacks.
3939

4040
.. note::
4141

42-
:ref:`Argon2i <reference-security-argon2i>` is the hashing algorithm as
42+
:ref:`Sodium <reference-security-sodium>` is the hashing algorithm as
4343
recommended by industry standards, but this won't be available to you unless
4444
you are using PHP 7.2+ or have the `libsodium`_ extension installed.
4545
``bcrypt`` is sufficient for most applications.

trunk/bundles/best_practices.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ of Symfony and the latest beta release:
197197
include:
198198
# Minimum supported dependencies with the latest and oldest PHP version
199199
- php: 7.2
200-
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
200+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="max[self]=0"
201201
- php: 7.0
202-
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
202+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="max[self]=0"
203203
204204
# Test the latest stable release
205205
- php: 7.0

trunk/cache.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,16 @@ The global clearer clears all the cache in every pool. The system cache clearer
623623
is used in the ``bin/console cache:clear`` command. The app clearer is the default
624624
clearer.
625625

626+
To see all available cache pools:
627+
628+
.. code-block:: terminal
629+
630+
$ php bin/console cache:pool:list
631+
632+
.. versionadded:: 4.3
633+
634+
The ``cache:pool:list`` command was introduced in Symfony 4.3.
635+
626636
Clear one pool:
627637

628638
.. code-block:: terminal

trunk/components/browser_kit.rst

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ The BrowserKit Component
1010

1111
.. note::
1212

13-
The BrowserKit component can only make internal requests to your application.
14-
If you need to make requests to external sites and applications, consider
15-
using `Goutte`_, a simple web scraper based on Symfony Components.
13+
In Symfony versions prior to 4.3, the BrowserKit component could only make
14+
internal requests to your application. Starting from Symfony 4.3, this
15+
component can also :ref:`make HTTP requests to any public site <component-browserkit-external-requests>`
16+
when using it in combination with the :doc:`HttpClient component </components/http_client>`.
1617

1718
Installation
1819
------------
@@ -279,6 +280,41 @@ also delete all the cookies::
279280
// reset the client (history and cookies are cleared too)
280281
$client->restart();
281282

283+
.. _component-browserkit-external-requests:
284+
285+
Making External HTTP Requests
286+
-----------------------------
287+
288+
So far, all the examples in this article have assumed that you are making
289+
internal requests to your own application. However, you can run the exact same
290+
examples when making HTTP requests to external web sites and applications.
291+
292+
First, install and configure the :doc:`HttpClient component </components/http_client>`.
293+
Then, use the :class:`Symfony\\Component\\BrowserKit\\HttpBrowser` to create
294+
the client that will make the external HTTP requests::
295+
296+
use Symfony\Component\BrowserKit\HttpBrowser;
297+
use Symfony\Component\HttpClient\HttpClient;
298+
299+
$browser = new HttpBrowser(HttpClient::create());
300+
301+
You can now use any of the methods shown in this article to extract information,
302+
click links, submit forms, etc. This means that you no longer need to use a
303+
dedicated web crawler or scraper such as `Goutte`_::
304+
305+
$browser = new HttpBrowser(HttpClient::create());
306+
307+
$browser->request('GET', 'https://github.com');
308+
$browser->clickLink('Sign in');
309+
$browser->submitForm('Sign in', ['login' => '...', 'password' => '...']);
310+
$openPullRequests = trim($browser->clickLink('Pull requests')->filter(
311+
'.table-list-header-toggle a:nth-child(1)'
312+
)->text());
313+
314+
.. versionadded:: 4.3
315+
316+
The feature to make external HTTP requests was introduced in Symfony 4.3.
317+
282318
Learn more
283319
----------
284320

trunk/components/cache/adapters/redis_adapter.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,22 @@ Below are common examples of valid DSNs showing a combination of available value
9494
'redis:?host[localhost]&host[localhost:6379]&host[/var/run/redis.sock:]&auth=my-password&redis_cluster=1'
9595
);
9696

97+
`Redis Sentinel`_, which provides high availability for Redis, is also supported
98+
when using the Predis library. Use the ``redis_sentinel`` parameter to set the
99+
name of your service group::
100+
101+
RedisAdapter::createConnection(
102+
'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
103+
);
104+
97105
.. versionadded:: 4.2
98106

99107
The option to define multiple servers in a single DSN was introduced in Symfony 4.2.
100108

109+
.. versionadded:: 4.4
110+
111+
Redis Sentinel support was introduced in Symfony 4.4.
112+
101113
.. note::
102114

103115
See the :class:`Symfony\\Component\\Cache\\Traits\\RedisTrait` for more options
@@ -184,3 +196,4 @@ Available Options
184196
.. _`Predis`: https://packagist.org/packages/predis/predis
185197
.. _`Predis Connection Parameters`: https://github.com/nrk/predis/wiki/Connection-Parameters#list-of-connection-parameters
186198
.. _`TCP-keepalive`: https://redis.io/topics/clients#tcp-keepalive
199+
.. _`Redis Sentinel`: https://redis.io/topics/sentinel

trunk/components/cache/psr6_psr16_adapters.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,23 @@ example::
3333

3434
But, you already have a PSR-16 cache object, and you'd like to pass this to the class
3535
instead. No problem! The Cache component provides the
36-
:class:`Symfony\\Component\\Cache\\Adapter\\SimpleCacheAdapter` class for exactly
36+
:class:`Symfony\\Component\\Cache\\Adapter\\Psr16Adapter` class for exactly
3737
this use-case::
3838

39-
use Symfony\Component\Cache\Adapter\SimpleCacheAdapter;
40-
use Symfony\Component\Cache\Simple\FilesystemCache;
39+
use Symfony\Component\Cache\Adapter\Psr16Adapter;
4140

42-
// the PSR-16 cache object that you want to use
43-
$psr16Cache = new FilesystemCache();
41+
// $psr16Cache is the PSR-16 object that you want to use as a PSR-6 one
4442

4543
// a PSR-6 cache that uses your cache internally!
46-
$psr6Cache = new SimpleCacheAdapter($psr16Cache);
44+
$psr6Cache = new Psr16Adapter($psr16Cache);
4745

4846
// now use this wherever you want
4947
$githubApiClient = new GitHubApiClient($psr6Cache);
5048

49+
.. versionadded:: 4.3
50+
51+
The ``Psr16Adapter`` class was introduced in Symfony 4.3.
52+
5153
Using a PSR-6 Cache Object as a PSR-16 Cache
5254
--------------------------------------------
5355

@@ -70,11 +72,11 @@ example::
7072

7173
But, you already have a PSR-6 cache pool object, and you'd like to pass this to
7274
the class instead. No problem! The Cache component provides the
73-
:class:`Symfony\\Component\\Cache\\Simple\\Psr6Cache` class for exactly
75+
:class:`Symfony\\Component\\Cache\\Psr16Cache` class for exactly
7476
this use-case::
7577

7678
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
77-
use Symfony\Component\Cache\Simple\Psr16Cache;
79+
use Symfony\Component\Cache\Psr16Cache;
7880

7981
// the PSR-6 cache object that you want to use
8082
$psr6Cache = new FilesystemAdapter();
@@ -85,4 +87,8 @@ this use-case::
8587
// now use this wherever you want
8688
$githubApiClient = new GitHubApiClient($psr16Cache);
8789

90+
.. versionadded:: 4.3
91+
92+
The ``Psr16Cache`` class was introduced in Symfony 4.3.
93+
8894
.. _`PSR-16`: http://www.php-fig.org/psr/psr-16/

trunk/components/console/helpers/progressbar.rst

Lines changed: 27 additions & 0 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,33 @@ that the progress bar display is refreshed with a 100% completion.
9595
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::display`
9696
to show the progress bar again.
9797

98+
If the progress information is stored in an iterable variable (such as an array
99+
or a PHP generator) you can use the
100+
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::iterate` method,
101+
which starts, advances and finishes the progress bar automatically::
102+
103+
use Symfony\Component\Console\Helper\ProgressBar;
104+
105+
$progressBar = new ProgressBar($output);
106+
107+
// $iterable can be for example an array ([1, 2, 3, ...]) or a generator
108+
// $iterable = function () { yield 1; yield 2; ... };
109+
foreach ($progressBar->iterate($iterable) as $value) {
110+
// ... do some work
111+
}
112+
113+
If ``$iterable = [1, 2]``, the previous code will output the following:
114+
115+
.. code-block:: terminal
116+
117+
0/2 [>---------------------------] 0%
118+
1/2 [==============>-------------] 50%
119+
2/2 [============================] 100%
120+
121+
.. versionadded:: 4.3
122+
123+
The ``iterate()`` method was introduced in Symfony 4.3.
124+
98125
Customizing the Progress Bar
99126
----------------------------
100127

trunk/components/console/helpers/questionhelper.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,43 @@ will be autocompleted as the user types::
179179
$bundleName = $helper->ask($input, $output, $question);
180180
}
181181

182+
In more complex use cases, it may be necessary to generate suggestions on the
183+
fly, for instance if you wish to autocomplete a file path. In that case, you can
184+
provide a callback function to dynamically generate suggestions::
185+
186+
use Symfony\Component\Console\Question\Question;
187+
188+
// ...
189+
public function execute(InputInterface $input, OutputInterface $output)
190+
{
191+
// This function is called whenever the input changes and new
192+
// suggestions are needed.
193+
$callback = function (string $userInput): array {
194+
// Strip any characters from the last slash to the end of the string
195+
// to keep only the last directory and generate suggestions for it
196+
$inputPath = preg_replace('%(/|^)[^/]*$%', '$1', $userInput);
197+
$inputPath = '' === $inputPath ? '.' : $inputPath;
198+
199+
// CAUTION - this example code allows unrestricted access to the
200+
// entire filesystem. In real applications, restrict the directories
201+
// where files and dirs can be found
202+
$foundFilesAndDirs = @scandir($inputPath) ?: [];
203+
204+
return array_map(function ($dirOrFile) use ($inputPath) {
205+
return $inputPath.$dirOrFile;
206+
}, $foundFilesAndDirs);
207+
};
208+
209+
$question = new Question('Please provide the full path of a file to parse');
210+
$question->setAutocompleterCallback($callback);
211+
212+
$filePath = $helper->ask($input, $output, $question);
213+
}
214+
215+
.. versionadded:: 4.3
216+
217+
The ``setAutocompleterCallback()`` method was introduced in Symfony 4.3.
218+
182219
Hiding the User's Response
183220
~~~~~~~~~~~~~~~~~~~~~~~~~~
184221

trunk/components/dom_crawler.rst

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ tree.
7070
isn't meant to dump content, you can see the "fixed" version of your HTML
7171
by :ref:`dumping it <component-dom-crawler-dumping>`.
7272

73+
.. note::
74+
75+
If you need better support for HTML5 contents or want to get rid of the
76+
inconsistencies of PHP's DOM extension, install the `html5-php library`_.
77+
The DomCrawler component will use it automatically when the content has
78+
an HTML5 doctype.
79+
80+
.. versionadded:: 4.3
81+
82+
The automatic support of the html5-php library was introduced in Symfony 4.3.
83+
7384
Node Filtering
7485
~~~~~~~~~~~~~~
7586

@@ -202,6 +213,13 @@ Access the value of the first node of the current selection::
202213
// if the node does not exist, calling to text() will result in an exception
203214
$message = $crawler->filterXPath('//body/p')->text();
204215

216+
// avoid the exception passing an argument that text() returns when node does not exist
217+
$message = $crawler->filterXPath('//body/p')->text('Default text content');
218+
219+
.. versionadded:: 4.3
220+
221+
The default argument of ``text()`` was introduced in Symfony 4.3.
222+
205223
Access the attribute value of the first node of the current selection::
206224

207225
$class = $crawler->filterXPath('//body/p')->attr('class');
@@ -210,12 +228,17 @@ Extract attribute and/or node values from the list of nodes::
210228

211229
$attributes = $crawler
212230
->filterXpath('//body/p')
213-
->extract(['_text', 'class'])
231+
->extract(['_name', '_text', 'class'])
214232
;
215233

216234
.. note::
217235

218-
Special attribute ``_text`` represents a node value.
236+
Special attribute ``_text`` represents a node value, while ``_name``
237+
represents the element name (the HTML tag name).
238+
239+
.. versionadded:: 4.3
240+
241+
The special attribute ``_name`` was introduced in Symfony 4.3.
219242

220243
Call an anonymous function on each node of the list::
221244

@@ -307,6 +330,13 @@ and :phpclass:`DOMNode` objects::
307330
// if the node does not exist, calling to html() will result in an exception
308331
$html = $crawler->html();
309332

333+
// avoid the exception passing an argument that html() returns when node does not exist
334+
$html = $crawler->html('Default <strong>HTML</strong> content');
335+
336+
.. versionadded:: 4.3
337+
338+
The default argument of ``html()`` was introduced in Symfony 4.3.
339+
310340
Expression Evaluation
311341
~~~~~~~~~~~~~~~~~~~~~
312342

@@ -568,11 +598,12 @@ the whole form or specific field(s)::
568598
$form->disableValidation();
569599
$form['country']->select('Invalid value');
570600

571-
.. _`Goutte`: https://github.com/FriendsOfPHP/Goutte
572-
.. _Packagist: https://packagist.org/packages/symfony/dom-crawler
573-
574601
Learn more
575602
----------
576603

577604
* :doc:`/testing`
578605
* :doc:`/components/css_selector`
606+
607+
.. _`Goutte`: https://github.com/FriendsOfPHP/Goutte
608+
.. _Packagist: https://packagist.org/packages/symfony/dom-crawler
609+
.. _`html5-php library`: https://github.com/Masterminds/html5-php

0 commit comments

Comments
 (0)
0