Download the PHP package vesihiisi/ctable without Composer

On this page you can find all versions of the php package vesihiisi/ctable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ctable

CTable

Introduction

Ctable is a PHP class for generating HTML tables out of data in arrays. It was created as part of the course DV1486 Databased Web Applications with PHP and MVC framework at Blekinge Institute of Technology, Sweden.

It is intended to be used with Anax MVC, but is not dependent on it. It can be included in any other project.

How to install

To install CTable from Packagist, put this line in your composer.json file:

"require": {
    ...
    "vesihiisi/ctable": "dev-master"
}

If you're using Anax-MVC, you can use the example files included in this repository to test how CTable works with the framework. Put the pagecontroller webroot/tables.php and the stylesheet css/tables.css in your own webroot directory and point your browser to the controller.

How to use

How to create a table

The data that you want to display in a table should be an array of arrays. Each inside array corresponds to one table row. Together, all the rows are collected in an outside array:

$rows = array(
    array("Row 1 value 1", "Row 1 value 2", "Row 1 value 3", "Row 1 value 4",),
    array("Row 2 value 1", "Row 2 value 2", "Row 2 value 3", "Row 2 value 4",),
    array("Row 3 value 1", "Row 3 value 2", "Row 3 value 3", "Row 3 value 4",),
    array("Row 4 value 1", "Row 4 value 2", "Row 4 value 3", "Row 4 value 4",),
    array("Row 5 value 1", "Row 5 value 2", "Row 5 value 3", "Row 5 value 4",),
    );

Then you might want to add the table headings, also as an array. It is not necessary, though – if you fail to do so, the first row of your data will be used as headings.

$headers = array(
    "Header 1", "Header 2", "Header 3", "Header 4",
    );

You can now create the table object and feed it in your data. This is how it would be done in Anax MVC:

$table = new \Vesihiisi\CTable\CTable([
    'rows' => $rows,
    'headers' => $headers,
    ]);

Once the object is created, you can also add new rows one by one:

$table->addRow(["Extra row value 1", "Extra row value 2", "Extra row value 3", "Extra row value 4"]);

Finally, in order to actually render the table, you must use the object's View() method and display the result in your view:

    $app->views->add('default/page', [
    'content' => $table->View(),
    'title' => "Demonstration of tables in HTML"
]);

Optional elements

There is a number of optional elements that you might want to add to your table.

Footer content can be defined before creating the object. Then, you feed it to the object, just like you did with the $data and $headers variables:

$footer = array(
    "Footer 1", "Footer 2", "Footer 3", "Footer 4",
    );

You can also define it after creating the object:

$table->setFooters(["Footer 1", "Footer 2", "Footer 3", "Footer 4"]);

Table caption (the <caption> tag) can also be created in two ways:

$caption = "Example data";

$table->setCaption("Example data");

CSS classes and ID can be added to the <table> tag. Those can also be created in two ways:

$classes = array(
    "someClass",
    "anotherClass",
    );
$id = "table01";

$table->setClass(["someClass", "anotherClass"]);
$table->setID("table01");

License

This software is free software and carries a MIT license.

Build Status Scrutinizer Code Quality Code Coverage Code Climate Issue Count Total Downloads Latest Stable Version


All versions of ctable with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vesihiisi/ctable contains the following files

Loading the files please wait ....