Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 08e5ac9

Browse filesBrowse files
committed
feature #4658 Debug formatter tweaks (weaverryan)
This PR was merged into the 2.6 branch. Discussion ---------- Debug formatter tweaks | Q | A | ------------- | --- | Doc fix? | no | New docs? | no | Applies to | 2.6+ | Fixed tickets | n/a Hi guys! This follows with a few tweaks to #4485. The biggest was adding an image of the output early on, which helped me understand "what the heck does this debug formatter actually do?". Thanks! Commits ------- 9e4eb5a language tweak thanks to xabbuh! 0f4fda7 Adding an example image of the debug_formatter
2 parents cfad26c + 9e4eb5a commit 08e5ac9
Copy full SHA for 08e5ac9

File tree

Expand file treeCollapse file tree

2 files changed

+30
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+30
-9
lines changed

‎components/console/helpers/debug_formatter.rst

Copy file name to clipboardExpand all lines: components/console/helpers/debug_formatter.rst
+30-9Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ Debug Formatter Helper
99

1010
The :class:`Symfony\\Component\\Console\\Helper\\DebugFormatterHelper` provides
1111
functions to output debug information when running an external program, for
12-
instance a process or HTTP request. It is included in the default helper set
13-
and you can get it by calling
14-
:method:`Symfony\\Component\\Console\\Command\\Command::getHelper`::
12+
instance a process or HTTP request. For example, if you used it to output
13+
the results of running ``ls -la`` on a UNIX system, it might output something
14+
like this:
15+
16+
.. image:: /images/components/console/debug_formatter.png
17+
:align: center
18+
19+
Using the debug_formatter
20+
-------------------------
21+
22+
The formatter is included in the default helper set and you can get it by
23+
calling :method:`Symfony\\Component\\Console\\Command\\Command::getHelper`::
1524

1625
$debugFormatter = $this->getHelper('debug_formatter');
1726

18-
The formatter only formats strings, which you can use to output to the console,
19-
but also to log the information or do anything else.
27+
The formatter accepts strings and returns a formatted string, which you then
28+
output to the console (or even log the information or do anything else).
2029

2130
All methods of this helper have an identifier as the first argument. This is a
2231
unique value for each program. This way, the helper can debug information for
@@ -39,9 +48,13 @@ display information that the program is started::
3948

4049
// ...
4150
$process = new Process(...);
42-
$process->run();
4351

44-
$output->writeln($debugFormatter->start(spl_object_hash($process), 'Some process description'));
52+
$output->writeln($debugFormatter->start(
53+
spl_object_hash($process),
54+
'Some process description')
55+
);
56+
57+
$process->run();
4558

4659
This will output:
4760

@@ -51,7 +64,11 @@ This will output:
5164
5265
You can tweak the prefix using the third argument::
5366

54-
$output->writeln($debugFormatter->start(spl_object_hash($process), 'Some process description', 'STARTED');
67+
$output->writeln($debugFormatter->start(
68+
spl_object_hash($process),
69+
'Some process description',
70+
'STARTED'
71+
);
5572
// will output:
5673
// STARTED Some process description
5774

@@ -69,7 +86,11 @@ using
6986

7087
$process->run(function ($type, $buffer) use ($output, $debugFormatter, $process) {
7188
$output->writeln(
72-
$debugFormatter->progress(spl_object_hash($process), $buffer, Process::ERR === $type)
89+
$debugFormatter->progress(
90+
spl_object_hash($process),
91+
$buffer,
92+
Process::ERR === $type
93+
)
7394
);
7495
});
7596
// ...
174 KB
Loading

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.