PHPackages                             jamesmcfadden/surface-extended - 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. jamesmcfadden/surface-extended

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

jamesmcfadden/surface-extended
==============================

Flexible HTML table generation in PHP

042[1 PRs](https://github.com/devyanlab/surface/pulls)PHP

Since Aug 17Pushed 10y ago1 watchersCompare

[ Source](https://github.com/devyanlab/surface)[ Packagist](https://packagist.org/packages/jamesmcfadden/surface-extended)[ RSS](/packages/jamesmcfadden-surface-extended/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Surface
=======

[](#surface)

Surface allows the generation of semantically correct HTML tables through a fluent and easy to use interface.

It is designed to be as flexible as possible, and supports attributes and table nesting.

\##Requirements

- PHP 5.3 due to the use of namespaces and closures

\##Usage ###Simple Table Creating a table is easy:

```
// Some data
$rows = array(
    array('China', '1,354,040,000', '19.07'),
	array('India', '1,210,569,573', '17.05'),
	array('United States', '316,278,000', '4.46'),
	array('Indonesia', '237,641,326', '3.35'),
	array('Brazil', '193,946,886', '2.73')
);

// Create
$surface = new Surface\Surface();

// Configure
$surface->setHead(array('Country', 'Population', '% of world'))
  ->addRows($rows);

// Render
echo $surface->render();

```

The above would output the following HTML:

```

			Country
			Population
			% of world

			China
			1,354,040,000
			19.07

			India
			1,210,569,573
			17.05

			United States
			316,278,000
			4.46

			Indonesia
			237,641,326
			3.35

			Brazil
			193,946,886
			2.73

```

\###Table Footer

To add a footer to a table, simply use the `setFoot()` method:

```
$surface->setHead(array('Country', 'Population', '% of world'))
        ->addRows($rows)
        ->setFoot(array('Total', 'Some total figure here'));

echo $surface->render();

```

This will generate table HTML making use of the `` element:

```

			Country
			Population
			% of world

			Total
			Some total figure here

			China
			1,354,040,000
			19.07

			India
			1,210,569,573
			17.05

			United States
			316,278,000
			4.46

			Indonesia
			237,641,326
			3.35

			Brazil
			193,946,886
			2.73

```

\###Using attributes

It is possible to manage parts of Surface at an element level, meaning you can give each element it's own attributes:

```
// Create a table as usual, we can pass some attributes too
$surface = new Surface\Surface(array('id' => 'population-data'));
$surface->setHead(array('Country', 'Population', '% of world'))
  ->addRows($rows);

// Some new data to add to existing rows
$newData = array(
    'Pakistan',

    // We can specify and manipulate the data at this level
	new Surface\Data('183,711,000', array('class' => 'td-green-highlight')),
	'2.59'
);

// Construct a new row and pass it to the table
$row = new Surface\Row($newData, array('class' => 'custom-row'));
$surface->addRow($row);

// Render
echo $surface->render();

```

\###Nested Tables

Nesting tables is also easy to achieve with Surface. Simply pass an existing table through to a new table as a data item:

```
// $nestedTable created up here

$parentTable = new Surface\Surface();
$parentTable->setHead(array('Country', 'Population', '% of world'))
  ->addRows($rows)
  ->addRow(array($nestedTable)); // $nestedTable is an instance of Surface\Surface

// Easy!
echo $parentTable->render();

```

This produces the following output:

```

			Country
			Population
			% of world

			China
			1,354,040,000
			19.07

			India
			1,210,569,573
			17.05

			United States
			316,278,000
			4.46

			Indonesia
			237,641,326
			3.35

			Brazil
			193,946,886
			2.73

						Id
						Name
						Date Created

							845
							User 845
							2013-01-01

							384
							User 384
							2012-05-10

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.6% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/93689bb53177eaee50ee7117b8b2f237a58b84acc155259eb45446dd28860ecc?d=identicon)[devyanlab](/maintainers/devyanlab)

---

Top Contributors

[![devloe](https://avatars.githubusercontent.com/u/122845?v=4)](https://github.com/devloe "devloe (5 commits)")[![mcfdn](https://avatars.githubusercontent.com/u/998911?v=4)](https://github.com/mcfdn "mcfdn (4 commits)")

### Embed Badge

![Health badge](/badges/jamesmcfadden-surface-extended/health.svg)

```
[![Health](https://phpackages.com/badges/jamesmcfadden-surface-extended/health.svg)](https://phpackages.com/packages/jamesmcfadden-surface-extended)
```

PHPackages © 2026

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