@@ -67,7 +67,7 @@ This exampe would output the following:
67
67
├── templates/
68
68
└── tests/
69
69
70
- The given contents can be defined in a multi-dimensional array:
70
+ The given contents can be defined in a multi-dimensional array::
71
71
72
72
$tree = TreeHelper::createTree($io, null, [
73
73
'src' => [
@@ -125,126 +125,132 @@ Built-in Tree Styles
125
125
~~~~~~~~~~~~~~~~~~~~
126
126
127
127
The tree helper provides a few built-in styles that you can use to customize the
128
- output of the tree.
129
-
130
- :method: `Symfony\\ Component\\ Console\\ Helper\\ TreeStyle::default `
131
-
132
- .. code-block :: terminal
133
-
134
- ├── config
135
- │ ├── packages
136
- │ └── routes
137
- │ ├── framework.yaml
138
- │ └── web_profiler.yaml
139
- ├── src
140
- │ ├── Command
141
- │ ├── Controller
142
- │ │ └── DefaultController.php
143
- │ └── Kernel.php
144
- └── templates
145
- └── base.html.twig
146
-
147
- :method: `Symfony\\ Component\\ Console\\ Helper\\ TreeStyle::box `
148
-
149
- .. code-block :: terminal
150
-
151
- ┃╸ config
152
- ┃ ┃╸ packages
153
- ┃ ┗╸ routes
154
- ┃ ┃╸ framework.yaml
155
- ┃ ┗╸ web_profiler.yaml
156
- ┃╸ src
157
- ┃ ┃╸ Command
158
- ┃ ┃╸ Controller
159
- ┃ ┃ ┗╸ DefaultController.php
160
- ┃ ┗╸ Kernel.php
161
- ┗╸ templates
162
- ┗╸ base.html.twig
163
-
164
- :method: `Symfony\\ Component\\ Console\\ Helper\\ TreeStyle::doubleBox `
165
-
166
- .. code-block :: terminal
167
-
168
- ╠═ config
169
- ║ ╠═ packages
170
- ║ ╚═ routes
171
- ║ ╠═ framework.yaml
172
- ║ ╚═ web_profiler.yaml
173
- ╠═ src
174
- ║ ╠═ Command
175
- ║ ╠═ Controller
176
- ║ ║ ╚═ DefaultController.php
177
- ║ ╚═ Kernel.php
178
- ╚═ templates
179
- ╚═ base.html.twig
180
-
181
- :method: `Symfony\\ Component\\ Console\\ Helper\\ TreeStyle::compact `
182
-
183
- .. code-block :: terminal
184
-
185
- ├ config
186
- │ ├ packages
187
- │ └ routes
188
- │ ├ framework.yaml
189
- │ └ web_profiler.yaml
190
- ├ src
191
- │ ├ Command
192
- │ ├ Controller
193
- │ │ └ DefaultController.php
194
- │ └ Kernel.php
195
- └ templates
196
- └ base.html.twig
197
-
198
- :method: `Symfony\\ Component\\ Console\\ Helper\\ TreeStyle::light `
199
-
200
- .. code-block :: terminal
201
-
202
- |-- config
203
- | |-- packages
204
- | `-- routes
205
- | |-- framework.yaml
206
- | `-- web_profiler.yaml
207
- |-- src
208
- | |-- Command
209
- | |-- Controller
210
- | | `-- DefaultController.php
211
- | `-- Kernel.php
212
- `-- templates
213
- `-- base.html.twig
214
-
215
- :method: `Symfony\\ Component\\ Console\\ Helper\\ TreeStyle::minimal `
216
-
217
- .. code-block :: terminal
218
-
219
- . config
220
- . . packages
221
- . . routes
222
- . . framework.yaml
223
- . . web_profiler.yaml
224
- . src
225
- . . Command
226
- . . Controller
227
- . . . DefaultController.php
228
- . . Kernel.php
229
- . templates
230
- . base.html.twig
231
-
232
- :method: `Symfony\\ Component\\ Console\\ Helper\\ TreeStyle::rounded `
233
-
234
- .. code-block :: terminal
235
-
236
- ├─ config
237
- │ ├─ packages
238
- │ ╰─ routes
239
- │ ├─ framework.yaml
240
- │ ╰─ web_profiler.yaml
241
- ├─ src
242
- │ ├─ Command
243
- │ ├─ Controller
244
- │ │ ╰─ DefaultController.php
245
- │ ╰─ Kernel.php
246
- ╰─ templates
247
- ╰─ base.html.twig
128
+ output of the tree::
129
+
130
+ use Symfony\Component\Console\Helper\TreeStyle;
131
+ // ...
132
+
133
+ $tree = TreeHelper::createTree($io, $node, [], TreeStyle::compact());
134
+ $tree->render();
135
+
136
+ ``TreeHelper::createTree($io, $node, [], TreeStyle::default()) `` (`details `_)
137
+
138
+ .. code-block :: terminal
139
+
140
+ ├── config
141
+ │ ├── packages
142
+ │ └── routes
143
+ │ ├── framework.yaml
144
+ │ └── web_profiler.yaml
145
+ ├── src
146
+ │ ├── Command
147
+ │ ├── Controller
148
+ │ │ └── DefaultController.php
149
+ │ └── Kernel.php
150
+ └── templates
151
+ └── base.html.twig
152
+
153
+ ``TreeHelper::createTree($io, $node, [], TreeStyle::box()) `` (`details `_)
154
+
155
+ .. code-block :: terminal
156
+
157
+ ┃╸ config
158
+ ┃ ┃╸ packages
159
+ ┃ ┗╸ routes
160
+ ┃ ┃╸ framework.yaml
161
+ ┃ ┗╸ web_profiler.yaml
162
+ ┃╸ src
163
+ ┃ ┃╸ Command
164
+ ┃ ┃╸ Controller
165
+ ┃ ┃ ┗╸ DefaultController.php
166
+ ┃ ┗╸ Kernel.php
167
+ ┗╸ templates
168
+ ┗╸ base.html.twig
169
+
170
+ ``TreeHelper::createTree($io, $node, [], TreeStyle::doubleBox()) `` (`details `_)
171
+
172
+ .. code-block :: terminal
173
+
174
+ ╠═ config
175
+ ║ ╠═ packages
176
+ ║ ╚═ routes
177
+ ║ ╠═ framework.yaml
178
+ ║ ╚═ web_profiler.yaml
179
+ ╠═ src
180
+ ║ ╠═ Command
181
+ ║ ╠═ Controller
182
+ ║ ║ ╚═ DefaultController.php
183
+ ║ ╚═ Kernel.php
184
+ ╚═ templates
185
+ ╚═ base.html.twig
186
+
187
+ ``TreeHelper::createTree($io, $node, [], TreeStyle::compact()) `` (`details `_)
188
+
189
+ .. code-block :: terminal
190
+
191
+ ├ config
192
+ │ ├ packages
193
+ │ └ routes
194
+ │ ├ framework.yaml
195
+ │ └ web_profiler.yaml
196
+ ├ src
197
+ │ ├ Command
198
+ │ ├ Controller
199
+ │ │ └ DefaultController.php
200
+ │ └ Kernel.php
201
+ └ templates
202
+ └ base.html.twig
203
+
204
+ ``TreeHelper::createTree($io, $node, [], TreeStyle::light()) `` (`details `_)
205
+
206
+ .. code-block :: terminal
207
+
208
+ |-- config
209
+ | |-- packages
210
+ | `-- routes
211
+ | |-- framework.yaml
212
+ | `-- web_profiler.yaml
213
+ |-- src
214
+ | |-- Command
215
+ | |-- Controller
216
+ | | `-- DefaultController.php
217
+ | `-- Kernel.php
218
+ `-- templates
219
+ `-- base.html.twig
220
+
221
+ ``TreeHelper::createTree($io, $node, [], TreeStyle::minimal()) `` (`details `_)
222
+
223
+ .. code-block :: terminal
224
+
225
+ . config
226
+ . . packages
227
+ . . routes
228
+ . . framework.yaml
229
+ . . web_profiler.yaml
230
+ . src
231
+ . . Command
232
+ . . Controller
233
+ . . . DefaultController.php
234
+ . . Kernel.php
235
+ . templates
236
+ . base.html.twig
237
+
238
+ ``TreeHelper::createTree($io, $node, [], TreeStyle::rounded()) `` (`details `_)
239
+
240
+ .. code-block :: terminal
241
+
242
+ ├─ config
243
+ │ ├─ packages
244
+ │ ╰─ routes
245
+ │ ├─ framework.yaml
246
+ │ ╰─ web_profiler.yaml
247
+ ├─ src
248
+ │ ├─ Command
249
+ │ ├─ Controller
250
+ │ │ ╰─ DefaultController.php
251
+ │ ╰─ Kernel.php
252
+ ╰─ templates
253
+ ╰─ base.html.twig
248
254
249
255
Making a Custom Tree Style
250
256
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -285,3 +291,5 @@ The above code will output the following tree:
285
291
🔵 🟢 🟠 🟡 Kernel.php
286
292
🔵 🟠 🟡 templates
287
293
🔵 🔴 🟠 🟡 base.html.twig
294
+
295
+ .. _`details` : https://github.com/symfony/symfony/blob/7.3/src/Symfony/Component/Console/Helper/TreeStyle.php
0 commit comments