PHPackages                             vkrtecek/table - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vkrtecek/table

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vkrtecek/table
==============

Basic table builder.

v1.1.5(7y ago)058MITPHPPHP &gt;=7.0.0

Since Aug 1Pushed 7y agoCompare

[ Source](https://github.com/vkrtecek/Table)[ Packagist](https://packagist.org/packages/vkrtecek/table)[ Docs](https://github.com/vkrtecek/table)[ RSS](/packages/vkrtecek-table/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (11)Used By (0)

Easy HTML Table generator
=========================

[](#easy-html-table-generator)

[![License](https://camo.githubusercontent.com/f45d904953153ca304a2328243d2733e095eee13a631a1f390709885d41dd692/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2f6672616d65776f726b2f6c6963656e73652e737667)](https://packagist.org/packages/laravel/framework)

The library focuses on easy table rendering of arrays of objects. No connections to database, only insert array.

License
-------

[](#license)

The Table library is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

Instalation
-----------

[](#instalation)

```
composer require vkrtecek/table
```

Examples
--------

[](#examples)

Let's say we have for all examples testing class like below:

```
class TestObject
{
    private $id;
    private $name;
    private $age;
    private $birthdate;

    public function __construct($id, $name, $age, $birthdate = NULL) {
        $this->id = $id;
        $this->name = $name;
        $this->age = $age;
    }

    public function getId() { return $this->id; }
    public function getName() { return $this->name; }
    public function getAge() { return $this->age; }
    public function getBirthDate() { return $this->birthdate; }
}
```

### Basic usage

[](#basic-usage)

If we want to render table with collection of TestObject, do:

```
$data = [
    new TestObject(1, 'John', 38),
    new TestObject(2, 'Susane', 35),
    new TestObject(3, 'Paul', 13),
    new TestObject(4, 'Joe', 25),
    new TestObject(5, 'Lucia', 80),
    new TestObject(6, 'Štěpán', 29, '1989-03-23'),
];

$table = \Vkrtecek\Table\Table::create($data)
   ->addColumn('ID of person')->setContent('id')
   ->addColumn('Name')->setContent('name')
   ->addColumn('Age')->setContent('age');

```

The string passed by `setContent()` must be the same string as signature of property's getter without `get`. So for example if the TestObject has method `getAge()`, `setContent()` must pass string `'age'` or `'Age'`.

And in your View call:

```

.
.
.

```

or

```
$table->renderHTML(['css' => true]);
```

so the result will look like

  ID of personNameAge   1John38 2Susane35 3Paul13 4Joe25 5Lucia80 6Štěpán29 ### Advanced

[](#advanced)

#### Callbacks

[](#callbacks)

We can specify a callback function instead of property name:

```
$table->addColumn('Name')->setContent(function (TestObject $obj) {
    return '' . $obj->getName() . '';
});
```

  ID of personNameAge   1*John*38 2*Susane*35 3*Paul*13 4*John*38 5*Susane*35 6*Paul*13 #### Sorting and filtering table data

[](#sorting-and-filtering-table-data)

Sometimes we need sort data by some attribute:

```
$table->addColumn('Name')->setOrderable()->setContent('name');
```

and now by clicking on the table column header, we can sort the rows by this column. Or `setOrderable()` pass one parameter of type callable to specify the style of sorting.

By typing code below the field for filtering of specific column data will appear:

```
$table->addColumn('Name')->setSearchable()->setContent('name');
```

If we don't want to show all rows and enable paging, which will render input for number of rows:

```
$table->enableListing();
```

#### Column class

[](#column-class)

Column can has it's own HTML class

```
$table->addColumn('ColName')->setClass('red');
```

#### Column filtering

[](#column-filtering)

Also for filtering by one single column, there is method `setSoloSearchable()` which pass string - URL attribute:

```
$table->addColumn('Name')->setSoloSearchable('url_name')->setContent('name');
```

will after any table action show URL like `http://my_Server/?...url_name=`and similar for date column

```
$table->addColumn('Name')->setDateFromToSearchable('url_from', 'url_to')->setContent('birthade');
```

the URL will look like `http://my_Server/?...url_from=&url_to=`for filtering column by "between dates".

If one of these filters are set, the button for show/hide the navigation row will appear above the table. If the "SHOW" button is clicked, navigation row will appear as the second THEAD row.

#### Additional

[](#additional)

If we want to sort and filter data by framework (e.g. QueryBuilder) and pass to table only filtered result set, call

```
$table = Table::create($rows)->setTotalItemCount(count($rows));
```

and table skip sorting, filtering and paging. By this integer value is also counted number of pages in listing, so insert the right number.

If is need to customize URL, use method `setNavigationNames` like below:

```
$table->setNavigationNames([
    'limit' => 'cust_limit',
    'orderBy' => 'cust_order_by',
    'order' => 'cust_order',
    'page' => 'cust_page',
    'pattern' => 'cust_pattern',
    'url' => 'my_Server'
])
```

will cause the URL will look after some table click action like `http://my_Server/?cust_order_by=Name&cust_order=ASC&cust_limit=5&cust_page=1&cust_pattern=`

Table is now multilingual and you can pass your own translations:

```
$table->renderHTML([
    'translations => [
        'Show navigation bar' => [string],  //button content
        'Hide navigation bar' => [string],  //button content
        'Search by' => [string],            //above table input's content
        'From' => [string],                 //in navigation row for dates
        'To' => [string],                   //in navigation row for dates
        'pattern' => [string],              //in navigation row for string searches
        'of' => [string],                   //in status bar (1 - 15 of 365)
    ]
]);
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Recently: every ~37 days

Total

9

Last Release

2715d ago

Major Versions

v0.0.1 → v1.0.02018-08-03

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23037100?v=4)[vkrtecek](/maintainers/vkrtecek)[@vkrtecek](https://github.com/vkrtecek)

---

Top Contributors

[![vkrtecek](https://avatars.githubusercontent.com/u/23037100?v=4)](https://github.com/vkrtecek "vkrtecek (14 commits)")

---

Tags

table

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vkrtecek-table/health.svg)

```
[![Health](https://phpackages.com/badges/vkrtecek-table/health.svg)](https://phpackages.com/packages/vkrtecek-table)
```

###  Alternatives

[wenzhixin/bootstrap-table

An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation)

11.8k286.2k1](/packages/wenzhixin-bootstrap-table)[nicolaskruchten/pivottable

Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.

4.4k219.4k1](/packages/nicolaskruchten-pivottable)[mottie/tablesorter

tablesorter (FORK) is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.

2.6k230.1k](/packages/mottie-tablesorter)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21259.6k](/packages/ramonrietdijk-livewire-tables)[nagarajanchinnasamy/subtotal

Subtotal.js is a JavaScript plugin for PivotTable.js. It renders subtotals of rows and columns with the ability to expand and collapse rows.

93133.3k](/packages/nagarajanchinnasamy-subtotal)[datatables.net/datatables.net

DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table. This is jQuery DataTables

58165.3k33](/packages/datatablesnet-datatablesnet)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
