Skip to content

Commit a299c16

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 9cd2c9f + ebaa7dc commit a299c16

File tree

20 files changed

+200
-50
lines changed

20 files changed

+200
-50
lines changed

.platform.app.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ disk: 512
4646
# Build time dependencies.
4747
dependencies:
4848
python:
49-
sphinx: "1.3.6"
49+
virtualenv: 15.1.0
5050

5151
# The hooks that will be performed when the package is deployed.
5252
hooks:
5353
build: |
54-
pip install git+https://github.com/fabpot/sphinx-php.git
54+
virtualenv .virtualenv
55+
. .virtualenv/bin/activate
56+
# Platform.sh currently sets PIP_USER=1.
57+
export PIP_USER=
58+
pip install pip==9.0.1 wheel==0.29.0
59+
pip install -r requirements.txt
5560
make -C _build html

components/console/helpers/progressbar.rst

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ current progress of the bar. Here is a list of the built-in placeholders:
170170
* ``remaining``: The remaining time to complete the task (not available if no max is defined);
171171
* ``estimated``: The estimated time to complete the task (not available if no max is defined);
172172
* ``memory``: The current memory usage;
173-
* ``message``: The current message attached to the progress bar.
173+
* ``message``: used to display arbitrary messages in the progress bar (as explained later).
174174

175175
For instance, here is how you could set the format to be the same as the
176176
``debug`` one::
@@ -181,20 +181,6 @@ Notice the ``:6s`` part added to some placeholders? That's how you can tweak
181181
the appearance of the bar (formatting and alignment). The part after the colon
182182
(``:``) is used to set the ``sprintf`` format of the string.
183183

184-
The ``message`` placeholder is a bit special as you must set the value
185-
yourself::
186-
187-
$bar->setMessage('Task starts');
188-
$bar->start();
189-
190-
$bar->setMessage('Task in progress...');
191-
$bar->advance();
192-
193-
// ...
194-
195-
$bar->setMessage('Task is finished');
196-
$bar->finish();
197-
198184
Instead of setting the format for a given instance of a progress bar, you can
199185
also define global formats::
200186

@@ -305,25 +291,41 @@ that displays the number of remaining steps::
305291
Custom Messages
306292
~~~~~~~~~~~~~~~
307293

308-
The ``%message%`` placeholder allows you to specify a custom message to be
309-
displayed with the progress bar. But if you need more than one, just define
310-
your own::
294+
Progress bars define a placeholder called ``message`` to display arbitrary
295+
messages. However, none of the built-in formats include that placeholder, so
296+
before displaying these messages, you must define your own custom format::
311297

312-
$bar->setMessage('Task starts');
313-
$bar->setMessage('', 'filename');
314-
$bar->start();
298+
$progressBar = new ProgressBar($output, 100);
299+
$progressBar->setFormatDefinition('custom', ' %current%/%max% -- %message%');
300+
$progressBar->setFormat('custom');
315301

316-
$bar->setMessage('Task is in progress...');
317-
while ($file = array_pop($files)) {
318-
$bar->setMessage($filename, 'filename');
319-
$bar->advance();
320-
}
302+
Now, use the ``setMessage()`` method to set the value of the ``%message%``
303+
placeholder before displaying the progress bar:
321304

322-
$bar->setMessage('Task is finished');
323-
$bar->setMessage('', 'filename');
324-
$bar->finish();
305+
// ...
306+
$progressBar->setMessage('Start');
307+
$progressBar->start();
308+
// 0/100 -- Start
309+
310+
$progressBar->advance();
311+
$progressBar->setMessage('Task is in progress...');
312+
// 1/100 -- Task is in progress...
313+
314+
Messages can be combined with custom placeholders too. In this example, the
315+
progress bar uses the ``%message%`` and ``%filename%`` placeholders::
325316

326-
For the ``filename`` to be part of the progress bar, just add the
327-
``%filename%`` placeholder in your format::
317+
$progressBar = new ProgressBar($output, 100);
318+
$progressBar->setFormatDefinition('custom', ' %current%/%max% -- %message% (%filename%)');
319+
$progressBar->setFormat('custom');
328320

329-
$bar->setFormat(" %message%\n %current%/%max%\n Working on %filename%");
321+
The ``setMessage()`` method accepts a second optional argument to set the value
322+
of the custom placeholders::
323+
324+
// ...
325+
// $files = array('client-001/invoices.xml', '...');
326+
foreach ($files as $filename) {
327+
$progressBar->setMessage('Importing invoices...');
328+
$progressBar->setMessage($filename, 'filename');
329+
$progressBar->advance();
330+
// 2/100 -- Importing invoices... (client-001/invoices.xml)
331+
}

components/console/helpers/questionhelper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ You can also use a validator with a hidden question::
295295
$question = new Question('Please enter your password');
296296
$question->setValidator(function ($value) {
297297
if (trim($value) == '') {
298-
throw new \Exception('The password can not be empty');
298+
throw new \Exception('The password cannot be empty');
299299
}
300300

301301
return $value;

components/dotenv.rst

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
.. index::
2+
single: Dotenv
3+
single: Components; Dotenv
4+
5+
The Dotenv Component
6+
====================
7+
8+
The Dotenv Component parses ``.env`` files to make environment variables
9+
stored in them accessible via ``getenv()``, ``$_ENV`` or ``$_SERVER``.
10+
11+
.. versionadded:: 3.3
12+
The Dotenv component was introduced in Symfony 3.3.
13+
14+
Installation
15+
------------
16+
17+
You can install the component in 2 different ways:
18+
19+
* :doc:`Install it via Composer </components/using_components>` (``symfony/dotenv`` on `Packagist`_);
20+
* Use the official Git repository (https://github.com/symfony/dotenv).
21+
22+
.. include:: /components/require_autoload.rst.inc
23+
24+
Usage
25+
-----
26+
27+
Sensitive information and environment-dependent settings should be defined as
28+
environment variables (as recommended for `twelve-factor applications`_). Using
29+
a ``.env`` file to store those environment variables eases development and CI
30+
management by keeping them in one "standard" place and agnostic of the
31+
technology stack you are using (Nginx vs PHP built-in server for instance).
32+
33+
.. note::
34+
35+
PHP has a lot of different implementations of this "pattern". This
36+
implementation's goal is to replicate what ``source .env`` would do. It
37+
tries to be as similar as possible with the standard shell's behavior (so
38+
no value validation for instance).
39+
40+
Load a ``.env`` file in your PHP application via ``Dotenv::load()``::
41+
42+
use Symfony\Component\Dotenv\Dotenv;
43+
44+
$dotenv = new Dotenv();
45+
$dotenv->load(__DIR__.'/.env');
46+
47+
// You can also load several files
48+
$dotenv->load(__DIR__.'/.env', __DIR__.'/.env.dev');
49+
50+
Given the following ``.env`` file content:
51+
52+
.. code-block:: bash
53+
54+
# .env
55+
DB_USER=root
56+
DB_PASS=pass
57+
58+
Access the value with ``getenv()`` in your code::
59+
60+
$dbUser = getenv('DB_USER');
61+
// you can also use ``$_ENV`` or ``$_SERVER``
62+
63+
.. note::
64+
65+
Symfony Dotenv never overwrites existing environment variables.
66+
67+
You should never store a ``.env`` file in your code repository as it might
68+
contain sensitive information; create a ``.env.dist`` file with sensible
69+
defaults instead.
70+
71+
Symfony Dotenv should only be used in development/testing/staging environments.
72+
For production environments, use "real" environment variables.
73+
74+
As a ``.env`` file is a regular shell script, you can ``source`` it in your own
75+
shell scripts:
76+
77+
.. code-block:: terminal
78+
79+
source .env
80+
81+
Add comments by prefixing them with ``#``:
82+
83+
.. code-block:: bash
84+
85+
# Database credentials
86+
DB_USER=root
87+
DB_PASS=pass # This is the secret password
88+
89+
Use environment variables in values by prefixing variables with ``$``:
90+
91+
.. code-block:: bash
92+
93+
DB_USER=root
94+
DB_PASS=${DB_USER}pass # Include the user as a password prefix
95+
96+
Embed commands via ``$()`` (not supported on Windows):
97+
98+
.. code-block:: bash
99+
100+
START_TIME=$(date)
101+
102+
.. note::
103+
104+
Note that using ``$()`` might not work depending on your shell.
105+
106+
.. _Packagist: https://packagist.org/packages/symfony/dotenv
107+
.. _twelve-factor applications: http://www.12factor.net/

components/filesystem.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,21 @@ complete new file (but never a partially-written file)::
283283

284284
The ``file.txt`` file contains ``Hello World`` now.
285285

286+
appendToFile
287+
~~~~~~~~~~~~
288+
289+
.. versionadded:: 3.3
290+
The :method:`Symfony\\Component\\Filesystem\\Filesystem::appendToFile`
291+
method was introduced in Symfony 3.3.
292+
293+
:method:`Symfony\\Component\\Filesystem\\Filesystem::appendToFile` adds new
294+
contents at the end of some file::
295+
296+
$fs->appendToFile('logs.txt', 'Email sent to user@example.com');
297+
298+
If either the file or its containing directory doesn't exist, this method
299+
creates them before appending the contents.
300+
286301
Error Handling
287302
--------------
288303

components/phpunit_bridge.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ namespaces in the ``phpunit.xml`` file, as done for example in the
345345
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
346346
<arguments>
347347
<array>
348-
<element><string>Symfony\Component\HttpFoundation</string></element>
348+
<element key="time-sensitive"><string>Symfony\Component\HttpFoundation</string></element>
349349
</array>
350350
</arguments>
351351
</listener>

components/process.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ Use :method:`Symfony\\Component\\Process\\Process::disableOutput` and
373373

374374
.. caution::
375375

376-
You can not enable or disable the output while the process is running.
376+
You cannot enable or disable the output while the process is running.
377377

378378
If you disable the output, you cannot access ``getOutput()``,
379379
``getIncrementalOutput()``, ``getErrorOutput()``, ``getIncrementalErrorOutput()`` or

components/var_dumper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ of your application may just break it by e.g. sending HTTP headers or
8888
corrupting your view, the bundle configures the ``dump()`` function so that
8989
variables are dumped in the web debug toolbar.
9090

91-
But if the toolbar can not be displayed because you e.g. called ``die``/``exit``
91+
But if the toolbar cannot be displayed because you e.g. called ``die``/``exit``
9292
or a fatal error occurred, then dumps are written on the regular output.
9393

9494
In a Twig template, two constructs are available for dumping a variable.

console/hide_commands.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ In those cases, you can define the command as **hidden** by setting the
3030

3131
Hidden commands behave the same as normal commands but they are no longer displayed
3232
in command listings, so end-users are not aware of their existence.
33+
34+
.. note::
35+
36+
Hidden commands are still available using the JSON or XML descriptor.

controller/soap_web_service.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ How to Create a SOAP Web Service in a Symfony Controller
88

99
Setting up a controller to act as a SOAP server is simple with a couple
1010
tools. You must, of course, have the `PHP SOAP`_ extension installed.
11-
As the PHP SOAP extension can not currently generate a WSDL, you must either
11+
As the PHP SOAP extension cannot currently generate a WSDL, you must either
1212
create one from scratch or use a 3rd party generator.
1313

1414
.. note::

0 commit comments

Comments
 (0)