Skip to content

Commit

Permalink
feature #6296 [Console] Add columns width setter documentation (akeeman)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

[Console] Add columns width setter documentation

Documentation for symfony/symfony#17761

Commits
-------

097fb65 remove support for "auto"
50a74fb Add columns width setter documentation
  • Loading branch information
weaverryan committed Mar 6, 2016
2 parents ceeab1a + 097fb65 commit 89bdbc6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions components/console/helpers/table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ You can add a table separator anywhere in the output by passing an instance of
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
+---------------+--------------------------+------------------+
The width of the columns are automatically set using the width of their contents by default. You can change this behavior via :method:`Symfony\\Component\\Console\\Helper\\Table::setColumnWidths`::

// Sets the left column to 10 characters, the middle to 0, and the right to 30 characters.
// The left two columns will effectively be 13 and 24 characters, as the columns' content don't fit within the set values.
$table->setColumnWidths(array(10, 0, 30));
$table->render();
This code results in:

.. code-block:: text
+---------------+--------------------------+--------------------------------+
| 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 |
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
+---------------+--------------------------+--------------------------------+
The table style can be changed to any built-in styles via
:method:`Symfony\\Component\\Console\\Helper\\Table::setStyle`::

Expand Down

0 comments on commit 89bdbc6

Please sign in to comment.