@@ -105,19 +105,30 @@ You can build a tree by creating a new instance of the
105
105
use Symfony\Component\Console\Helper\TreeHelper;
106
106
use Symfony\Component\Console\Helper\TreeNode;
107
107
108
- $node = TreeNode::fromValues([
109
- 'Command',
110
- 'Controller' => [
111
- 'DefaultController.php',
112
- ],
113
- 'Kernel.php',
114
- ]);
115
- $node->addChild('templates');
116
- $node->addChild('tests');
117
-
118
- $tree = TreeHelper::createTree($io, $node);
108
+ $root = new TreeNode('my-project/');
109
+ // you can pass a string directly or create a TreeNode object
110
+ $root->addChild('src/');
111
+ $root->addChild(new TreeNode('templates/'));
112
+
113
+ // create nested structures by adding child nodes to other nodes
114
+ $testsNode = new TreeNode('tests/');
115
+ $functionalTestsNode = new TreeNode('Functional/');
116
+ $testsNode->addChild($functionalTestsNode);
117
+ $root->addChild(testsNode);
118
+
119
+ $tree = TreeHelper::createTree($io, $root);
119
120
$tree->render();
120
121
122
+ This example outputs:
123
+
124
+ .. code-block :: terminal
125
+
126
+ my-project/
127
+ βββ src/
128
+ βββ templates/
129
+ βββ tests/
130
+ βββ Functional/
131
+
121
132
Customizing the Tree Style
122
133
--------------------------
123
134
@@ -133,7 +144,11 @@ output of the tree::
133
144
$tree = TreeHelper::createTree($io, $node, [], TreeStyle::compact());
134
145
$tree->render();
135
146
136
- ``TreeHelper::createTree($io, $node, [], TreeStyle::default()) `` (`details `_)
147
+ **Default **::
148
+
149
+ TreeHelper::createTree($io, $node, [], TreeStyle::default());
150
+
151
+ This outputs:
137
152
138
153
.. code-block :: terminal
139
154
@@ -150,7 +165,11 @@ output of the tree::
150
165
βββ templates
151
166
βββ base.html.twig
152
167
153
- ``TreeHelper::createTree($io, $node, [], TreeStyle::box()) `` (`details `_)
168
+ **Box **:
169
+
170
+ TreeHelper::createTree($io, $node, [], TreeStyle::box());
171
+
172
+ This outputs:
154
173
155
174
.. code-block :: terminal
156
175
@@ -167,7 +186,11 @@ output of the tree::
167
186
ββΈ templates
168
187
ββΈ base.html.twig
169
188
170
- ``TreeHelper::createTree($io, $node, [], TreeStyle::doubleBox()) `` (`details `_)
189
+ **Double box **::
190
+
191
+ TreeHelper::createTree($io, $node, [], TreeStyle::doubleBox());
192
+
193
+ This outputs:
171
194
172
195
.. code-block :: terminal
173
196
@@ -184,7 +207,11 @@ output of the tree::
184
207
ββ templates
185
208
ββ base.html.twig
186
209
187
- ``TreeHelper::createTree($io, $node, [], TreeStyle::compact()) `` (`details `_)
210
+ **Compact **::
211
+
212
+ TreeHelper::createTree($io, $node, [], TreeStyle::compact());
213
+
214
+ This outputs:
188
215
189
216
.. code-block :: terminal
190
217
@@ -201,7 +228,11 @@ output of the tree::
201
228
β templates
202
229
β base.html.twig
203
230
204
- ``TreeHelper::createTree($io, $node, [], TreeStyle::light()) `` (`details `_)
231
+ **Light **::
232
+
233
+ TreeHelper::createTree($io, $node, [], TreeStyle::light());
234
+
235
+ This outputs:
205
236
206
237
.. code-block :: terminal
207
238
@@ -218,7 +249,11 @@ output of the tree::
218
249
`-- templates
219
250
`-- base.html.twig
220
251
221
- ``TreeHelper::createTree($io, $node, [], TreeStyle::minimal()) `` (`details `_)
252
+ **Minimal **::
253
+
254
+ TreeHelper::createTree($io, $node, [], TreeStyle::minimal());
255
+
256
+ This outputs:
222
257
223
258
.. code-block :: terminal
224
259
@@ -235,7 +270,11 @@ output of the tree::
235
270
. templates
236
271
. base.html.twig
237
272
238
- ``TreeHelper::createTree($io, $node, [], TreeStyle::rounded()) `` (`details `_)
273
+ **Rounded **:
274
+
275
+ TreeHelper::createTree($io, $node, [], TreeStyle::rounded());
276
+
277
+ This outputs:
239
278
240
279
.. code-block :: terminal
241
280
@@ -291,5 +330,3 @@ The above code will output the following tree:
291
330
π΅ π’ π π‘ Kernel.php
292
331
π΅ π π‘ templates
293
332
π΅ π΄ π π‘ base.html.twig
294
-
295
- .. _`details` : https://github.com/symfony/symfony/blob/7.3/src/Symfony/Component/Console/Helper/TreeStyle.php
0 commit comments