class Table
Provides helpers to display a table.
SEPARATOR_TOP | |
SEPARATOR_TOP_BOTTOM | |
SEPARATOR_MID | |
SEPARATOR_BOTTOM | |
BORDER_OUTSIDE | |
BORDER_INSIDE |
__construct(OutputInterface $output) | ||
static | setStyleDefinition(string $name, TableStyle $style) Sets a style definition. | |
static TableStyle | getStyleDefinition(string $name) Gets a style definition by name. | |
$this | setStyle(TableStyle|string $name) Sets table style. | |
TableStyle | getStyle() Gets the current table style. | |
$this | setColumnStyle(int $columnIndex, TableStyle|string $name) Sets table column style. | |
TableStyle | getColumnStyle(int $columnIndex) Gets the current style for a column. | |
$this | setColumnWidth(int $columnIndex, int $width) Sets the minimum width of a column. | |
$this | setColumnWidths(array $widths) Sets the minimum width of all columns. | |
setHeaders(array $headers) | ||
setRows(array $rows) | ||
addRows(array $rows) | ||
addRow($row) | ||
Table | appendRow($row) Adds a row to the table, and re-renders the table. | |
setRow($column, array $row) | ||
render() Renders table to output. |
OutputInterface | $output |
Sets a style definition.
string | $name | The style name |
TableStyle | $style | A TableStyle instance |
Gets a style definition by name.
string | $name | The style name |
TableStyle |
Sets table style.
TableStyle|string | $name | The style name or a TableStyle instance |
$this |
Gets the current table style.
TableStyle |
Sets table column style.
int | $columnIndex | Column index |
TableStyle|string | $name | The style name or a TableStyle instance |
$this |
Gets the current style for a column.
If style was not set, it returns the global table style.
int | $columnIndex | Column index |
TableStyle |
Sets the minimum width of a column.
int | $columnIndex | Column index |
int | $width | Minimum column width in characters |
$this |
Sets the minimum width of all columns.
array | $widths |
$this |
array | $headers |
array | $rows |
array | $rows |
$row |
Adds a row to the table, and re-renders the table.
$row |
Table |
$column | ||
array | $row |
Renders table to output.
Example:
+---------------+-----------------------+------------------+
| ISBN | Title | Author |
+---------------+-----------------------+------------------+
| 99921-58-10-7 | Divine Comedy | Dante Alighieri |
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
| 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
+---------------+-----------------------+------------------+
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Console/Helper/Table.html