Download the PHP package serendipity_hq/php_text_matrix without Composer
On this page you can find all versions of the php package serendipity_hq/php_text_matrix. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download serendipity_hq/php_text_matrix
More information about serendipity_hq/php_text_matrix
Files in serendipity_hq/php_text_matrix
Package php_text_matrix
Short Description A PHP library to render an array representing a matrix as a plain text table.
License MIT
Homepage https://github.com/Aerendir/component-text-matrix
Informations about the package php_text_matrix
Serendipity HQ Text Matrix
Renders into a plain text table an array representing a matrix of data.
Current Status
Features
- Four direction padding (top, right, bottom and left) on a per column basis (following the CSS syntax);
- Max columns width, with possibility to cut words or to maintain their integrity (as the word-wrap CSS property);
- Left and right alignement on a per column basis;
- Customizable vertical, horizontal and cross separators, both for header and for content;
- Different default style for the header (the first row passed);
- Ability to remove the first line divider for the header;
Do you like this library?
LEAVE A ★
or run
composer global require symfony/thanks && composer thanks
to say thank you to all libraries you use in your current project, this included!
Install Serendipity HQ Text Matrix via Composer
$ composer require serendipity_hq/component-text-matrix
This library follows the http://semver.org/ versioning conventions.
How to use Serendipity HQ Text Matrix
component-text-matrix allows a great flexibility in rendering data as plain text tables. You can customize a lot of aspctes of your generated table.
If some feature is missed, you can open an issue and integrate it and submit a pull request. Remeber to test you new feature: not tested features will not be merged.
Basic usage
To use component-text-matrix you need only an array representing a matrix:
This will render a table like this:
Padding, columns max width and word wrapping
Passing some options to the render()
method it is possible to customize your plain text table:
This will generate the following table:
Customize Header and separators
This is the generated table:
Final notes
- Use the
cut
option setting it to tru or false to determine if the word can be broken or not (see thewordwrap
PHP function) - The padding follows the rules of the CSS
padding
rule, so: If the padding property has four values:- padding: 25px 50px 75px 100px;
- top padding is 25px
- right padding is 50px
- bottom padding is 75px
- left padding is 100px If the padding property has three values:
- padding: 25px 50px 75px;
- top padding is 25px
- right and left paddings are 50px
- bottom padding is 75px If the padding property has two values:
- padding: 25px 50px;
- top and bottom paddings are 25px
- right and left paddings are 50px If the padding property has one value:
- padding: 25px;
- all four paddings are 25px
If one value is passed, you can pass it a simple
integer
(ex.:['cells_padding' => 1]
) or as an array (ex.:['cells_padding' => [1]
).
- all four paddings are 25px
If one value is passed, you can pass it a simple
- padding: 25px 50px 75px 100px;
For more information, see the unit tests in the tests
folder, the methods resolveOptions()
(where all options are validated) or the examples.
Do you like this library?
LEAVE A ★
or run
composer global require symfony/thanks && composer thanks
to say thank you to all libraries you use in your current project, this included!
All versions of php_text_matrix with dependencies
ext-iconv Version *
symfony/options-resolver Version ^4.4|^5.4|^6.0
thecodingmachine/safe Version ^1.0|^2.0