Skip to content

Commit 1ef3db3

Browse files
committed
Merge branch '3.4' into 4.0
* 3.4: Added a short section about registering commands Explain which branch to select for Pull Requests Missing the obvious <?php Update email field length in annotation Removed a duplicated content Clarify Symfony Console option conventions Clarify how to use short options with values. Use the long array syntax Fixes deprecated ProcessBuilder usage
2 parents e7e8c8b + 2c16d07 commit 1ef3db3

File tree

6 files changed

+41
-17
lines changed

6 files changed

+41
-17
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!--
2+
3+
If your pull request fixes a BUG, use the oldest maintained branch that contains
4+
the bug (see https://symfony.com/roadmap for the list of maintained branches).
5+
6+
If your pull request documents a NEW FEATURE, use the same Symfony branch where
7+
the feature was introduced (and `master` for features of unreleased versions).
8+
9+
-->

components/console/helpers/processhelper.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ a very verbose verbosity (e.g. -vv)::
1414
use Symfony\Component\Process\ProcessBuilder;
1515

1616
$helper = $this->getHelper('process');
17-
$process = ProcessBuilder::create(array('figlet', 'Symfony'))->getProcess();
17+
$process = new Process(array('figlet', 'Symfony'));
1818

1919
$helper->run($output, $process);
2020

@@ -55,7 +55,7 @@ There are three ways to use the process helper:
5555
use Symfony\Component\Process\ProcessBuilder;
5656

5757
// ...
58-
$process = ProcessBuilder::create(array('figlet', 'Symfony'))->getProcess();
58+
$process = new Process(array('figlet', 'Symfony'));
5959

6060
$helper->run($output, $process);
6161

console.rst

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,23 @@ method. Then you can optionally define a help message and the
6969
;
7070
}
7171

72+
Registering the Command
73+
-----------------------
74+
75+
Symfony commands must be registered as services and :doc:`tagged </service_container/tags>`
76+
with the ``console.command`` tag. If you're using the
77+
:ref:`default services.yaml configuration <service-container-services-load-example>`,
78+
this is already done for you, thanks to :ref:`autoconfiguration <services-autoconfigure>`.
79+
7280
Executing the Command
7381
---------------------
7482

75-
You can now execute this command in the terminal:
83+
After configuring and registering the command, you can execute it in the terminal:
7684

7785
.. code-block:: terminal
7886
7987
$ php bin/console app:create-user
8088
81-
.. note::
82-
83-
The command class must be registered as a service with the ``console.command`` tag.
84-
85-
If you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
86-
this is already done for you, thanks to :ref:`autoconfiguration <services-autoconfigure>`.
87-
88-
Otherwise, you can manually register your command as a service by configuring the service
89-
and :doc:`tagging it </service_container/tags>` with ``console.command``.
90-
9189
As you might expect, this command will do nothing as you didn't write any logic
9290
yet. Add your own logic inside the ``execute()`` method, which has access to the
9391
input stream (e.g. options and arguments) and the output stream (to write

console/input.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ flag:
174174
1
175175
);
176176

177+
Note that to comply with the `docopt standard`_, long options can specify their
178+
values after a white space or an ``=`` sign (e.g. ``--iterations 5`` or
179+
``--iterations=5``), but short options can only use white spaces or no
180+
separation at all (e.g. ``-i 5`` or ``-i5``).
181+
177182
There are four option variants you can use:
178183

179184
``InputOption::VALUE_IS_ARRAY``
@@ -184,8 +189,8 @@ There are four option variants you can use:
184189
behavior of options;
185190

186191
``InputOption::VALUE_REQUIRED``
187-
This value is required (e.g. ``--iterations=5``), the option itself is
188-
still optional;
192+
This value is required (e.g. ``--iterations=5`` or ``-i5``), the option
193+
itself is still optional;
189194

190195
``InputOption::VALUE_OPTIONAL``
191196
This option may or may not have a value (e.g. ``--yell`` or
@@ -211,3 +216,14 @@ You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or
211216
when the option was used without a value (``command --language``) or when
212217
it wasn't used at all (``command``). In both cases, the value retrieved for
213218
the option will be ``null``.
219+
220+
.. caution::
221+
222+
While it is possible to separate an option from its value with a white space,
223+
using this form leads to an ambiguity should the option appear before the
224+
command name. For example, ``php bin/console --iterations 5 app:greet Fabien``
225+
is ambiguous; Symfony would interpret ``5`` as the command name. To avoid
226+
this situation, always place options after the command name, or avoid using
227+
a space to separate the option name from its value.
228+
229+
.. _`docopt standard`: http://docopt.org/

page_creation.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Suppose you want to create a page - ``/lucky/number`` - that generates a lucky (
4343
random) number and prints it. To do that, create a "Controller class" and a
4444
"controller" method inside of it::
4545

46+
<?php
4647
// src/Controller/LuckyController.php
4748
namespace App\Controller;
4849

@@ -281,7 +282,7 @@ project:
281282

282283
``src/``
283284
All your PHP code lives here.
284-
285+
285286
``templates/``
286287
All your Twig templates live here.
287288

security/entity_provider.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ with the following fields: ``id``, ``username``, ``password``,
6767
private $password;
6868

6969
/**
70-
* @ORM\Column(type="string", length=60, unique=true)
70+
* @ORM\Column(type="string", length=254, unique=true)
7171
*/
7272
private $email;
7373

0 commit comments

Comments
 (0)