Symfony 7.3 introduces powerful improvements to the Console component, beyond
the much-anticipated invokable commands and input attributes. This version also
brings new helpers and features designed to make console applications more capable.
Contributed by
Alexander Menk
in
#59657
The table helper lets you create complex tables with various structures and
formats. In Symfony 7.3, we've introduced a new style for generating tables in
Markdown format. This is useful, for example, when generating content for
GitHub/GitLab issues, pull requests, CI messages, and more.
use Symfony\Component\Console\Helper\Table;
// ...
$table = new Table($output);
$table
->setHeaders(['Version', 'Release Date', 'Is LTS?'])
->setRows([
['Symfony 7.0', 'November 2023', 'No'],
// ...
['...', '...', '...'],
])
;
$table->setStyle('markdown');
$table->render();
This outputs:
| Version | Release Date | Is LTS? |
|---------------|--------------------------|------------------|
| Symfony 7.0 | November 2023 | No |
| Symfony 7.1 | May 2024 | No |
| Symfony 7.2 | November 2024 | No |
| Symfony 7.3 | May 2025 | No |
| Symfony 7.4 | November 2025 | Yes |
Contributed by
Simon André
in
#59588
The Console component includes many helpers for rendering elements like
progress bars and prompts, for controlling the cursor, etc. In Symfony 7.3,
we've added a new helper for rendering tree-like structures.
This helper is typically used to render directory hierarchies but can handle any
tree-like data:
use Symfony\Component\Console\Helper\TreeHelper;
use Symfony\Component\Console\Style\SymfonyStyle;
// ...
$io = new SymfonyStyle($input, $output);
$tree = TreeHelper::createTree($io, null, [
'src' => [
'Command',
'Controller' => [
'DefaultController.php',
],
'Kernel.php',
],
'templates' => [
'base.html.twig',
],
]);
$tree->render();
This outputs:
├── src
│ ├── Command
│ ├── Controller
│ │ └── DefaultController.php
│ └── Kernel.php
└── templates
└── base.html.twig
If you don't know the tree elements beforehand, you can build the tree programmatically:
use Symfony\Component\Console\Helper\TreeNode;
// ...
$node = TreeNode::fromValues(['Command', 'Controller']);
// ...
$node->addChild('templates');
$node->addChild('tests');
The tree helper provides seven built-in styles (box, double, minimal, rounded,
etc.) and lets you create your own tree style.
Sponsor the Symfony project.